#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-1] ^ B[i+1]), 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);
if(f) {
for(int i=1; i<=N; i++) A[i] = (S[i-1] == '1');
A[0] = A[N+1] = B[0] = B[N+1] = 0;
f &= sim(N, 1);
if(N % 4 == 3 && f) f &= sim(N, min(130, N));
}
puts(f ? "LIVES" : "DIES");
}
// for(int k=1; k<=100; k++) {
// for(int j=1; j<=k; j++) A[j] = 0;
// A[1] = 1;
// if(!sim(k, 10000)) printf("k: %d\n", k);
// }
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
12 ms |
632 KB |
Output is correct |
4 |
Correct |
38 ms |
376 KB |
Output is correct |
5 |
Execution timed out |
1074 ms |
2540 KB |
Time limit exceeded |