Submission #978920


Source Code Expand

#include <cstdio>
#include <cmath>

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

typedef long long   signed int LL;
typedef long long unsigned int LU;

template<typename T> void swap(T &x, T &y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T &a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T &a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int h, w;
char a[8][9];
bool ans = false;

int main() {
	scanf("%d%d", &h, &w);
	inc(i, h) { scanf("%s", a[i]); }
	
	int memo[8][8];
	inc(i, 1 << (h + w - 1)) {
		inc(j, h) {
		inc(k, w) {
			memo[j][k] = 0;
		}
		}
		
		int hh = 0, ww = 0;
		bool flag1 = true;
		inc(j, h + w - 1) {
			if(hh < h && ww < w) { memo[hh][ww] = 1; } else { flag1 = false; break; }
			if(i & (1 << j)) { hh++; } else { ww++; }
		}
		if(! flag1) { continue; }
		
		inc(j, h) {
		inc(k, w) {
			if( (a[j][k] == '#') == (memo[j][k] == 1) ) { } else { flag1 = false; j = k = w + h; }
		}
		}
		if(flag1) { ans = true; break; }
	}
	
	printf("%s\n", ans ? "Possible" : "Impossible");
	
	return 0;
}

Submission Info

Submission Time
Task A - Shik and Stone
User FF256grhy
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1858 Byte
Status AC
Exec Time 5 ms
Memory 128 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:32:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &h, &w);
                       ^
./Main.cpp:33:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  inc(i, h) { scanf("%s", a[i]); }
                               ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 22
Set Name Test Cases
Sample example0.txt, example1.txt, example2.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, example0.txt, example1.txt, example2.txt
Case Name Status Exec Time Memory
000.txt AC 5 ms 128 KB
001.txt AC 5 ms 128 KB
002.txt AC 5 ms 128 KB
003.txt AC 5 ms 128 KB
004.txt AC 5 ms 128 KB
005.txt AC 5 ms 128 KB
006.txt AC 1 ms 128 KB
007.txt AC 1 ms 128 KB
008.txt AC 1 ms 128 KB
009.txt AC 1 ms 128 KB
010.txt AC 1 ms 128 KB
011.txt AC 1 ms 128 KB
012.txt AC 3 ms 128 KB
013.txt AC 2 ms 128 KB
014.txt AC 2 ms 128 KB
015.txt AC 2 ms 128 KB
016.txt AC 1 ms 128 KB
017.txt AC 2 ms 128 KB
018.txt AC 2 ms 128 KB
example0.txt AC 1 ms 128 KB
example1.txt AC 1 ms 128 KB
example2.txt AC 1 ms 128 KB