Submission #138525

# Submission time Handle Problem Language Result Execution time Memory
138525 2019-07-30T06:12:20 Z 이온조(#3319) Who wants to live forever? (CERC12_B) C++14
0 / 1
2 ms 256 KB
#include <bits/stdc++.h>
using namespace std;

char S[200009];
int A[200009], B[200009];

bool chk(int N) {
	int c = 50;
	while(c--) {
		for(int i=1; i<=N; i++) B[i] = (A[i-1] ^ A[i+1]);
		for(int i=1; i<=N; i++) A[i] = B[i];
	}
	bool f = 0;
	for(int i=1; i<=N; i++) f |= A[i];
	return f;
}

int main() {
	int T; scanf("%d",&T);
	while(T--) {
		scanf(" %s", S+1);
		int N = strlen(S+1);
		bool f = (N%4 != 3), o1 = 0, o2 = 0;
		for(int i=1; i<=N; i++) {
			if(S[i] == '1') o1 = 1;
			if(((i%2) ^ (S[i] == '0')) == 0) o2 = 1;
		}
		f &= o1;
		f &= o2;
		f &= (N != 1);
		puts(f ? "LIVES" : "DIES");
	}
	// for(int k=1; k<=10; k++) {
	// 	int cnt = 0;
	// 	for(int i=0; i<(1<<k); i++) {
	// 		for(int j=0; j<k; j++) A[j+1] = ((i >> j) & 1);
	// 		if(!chk(k)) {
	// 			for(int j=0; j<k; j++) printf("%d", ((i>>j) & 1));
	// 			puts("");
	// 			++cnt;
	// 		}
	// 	}
	// 	if(cnt > 2) printf("k: %d\n", k);
	// }

	return 0;
}

Compilation message

B.cpp: In function 'int main()':
B.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int T; scanf("%d",&T);
         ~~~~~^~~~~~~~~
B.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %s", S+1);
   ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -