Submission #138557

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

int A[200009], B[200009];

bool sim(int N, int c) {
	bool f1 = 0;
	while(c--) {
		f1 = 0;
		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], f1 |= A[i];
		if(!f1) break;
	}
	bool f = 0;
	for(int i=1; i<=N; i++) f |= A[i];
	return f;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	int T; cin >> T;
	while(T--) {
		string S; cin >> S;
		int N = S.size();
		bool f = (((N+1) &- (N+1)) != N+1);
		for(int i=1; i<=N; i++) A[i] = (S[i-1] == '1');
		A[0] = A[N+1] = 0;
		f &= sim(N, 3);
		if(N % 4 == 3 && f) f &= sim(N, 260);
		puts(f ? "LIVES" : "DIES");
	}
	// for(int k=1; k<=30; 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(!sim(k, 300)) {
	// 			for(int j=0; j<k; j++) printf("%d", ((i>>j) & 1));
	// 			puts("");
	// 			++cnt;
	// 		}
	// 		if(cnt > 50) break;
	// 	}
	// 	printf("k: %d, cnt: %d\n", k, cnt);
	// }
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 31 ms 760 KB Output is correct
4 Correct 58 ms 376 KB Output is correct
5 Execution timed out 1082 ms 2528 KB Time limit exceeded