Submission #138662

# Submission time Handle Problem Language Result Execution time Memory
138662 2019-07-30T08:15:20 Z 임유진(#3321) Who wants to live forever? (CERC12_B) C++14
0 / 1
2 ms 376 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++);

	bool b = true;
	for(int i = 0; i < N; i++) b &= A[i] == '0';
	if(b) return false;
	if(N % 2 == 0) return true;
	int two;
	for(two = 1; two <= N; two *= 2);
	if(two == N + 1) return false;
	b = A[0] == '1' && A[N] == '1';
	for(int i = 1; i < N; i++) b &= A[i] != A[i - 1];
	if(b) return false;
	b = N % 3 == 2 && A[N / 3 - 1] == '0' && A[N / 3 * 2 - 1] == '0';
	for(int i = 0; i < N / 3; i++) b &= A[i] == A[N / 3 * 2 - i] && A[i] == A[i + N / 3 * 2];
	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 352 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -