Submission #138684

# Submission time Handle Problem Language Result Execution time Memory
138684 2019-07-30T08:31:51 Z 임유진(#3321) Who wants to live forever? (CERC12_B) C++14
1 / 1
138 ms 1464 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 200100;

char A[MAXN];

bool solve() {
	int N;
	for(N = 0; A[N]; N++);

	for(int i = 0; 1 << i <= N + 1; i++) if((N + 1) % (1 << i) == 0) {
		bool b = true;
		for(int j = 1; b && j < (N + 1) / (1 << i); j++) if(A[j * (1 << i) - 1] == '1') b = false;
		for(int j = 0; j < (1 << i) - 1; j++) for(int k = 1; k < (N + 1) / (1 << i); k++) {
			if(k % 2) {
				if(A[j] != A[(1 << i) * (k + 1) - j - 2]) b = false;
			}
			else {
				if(A[j] != A[(1 << i) * k + j]) b = false;
			}
		}
		if(b) return false;
	}
	return true;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int T;

	cin >> T;
	while(T--) {
		cin >> A;
		if(solve()) cout << "LIVES\n";
		else cout << "DIES\n";
	}
	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 18 ms 1212 KB Output is correct
4 Correct 4 ms 504 KB Output is correct
5 Correct 138 ms 1464 KB Output is correct