# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
135913 | model_code | Who wants to live forever? (CERC12_B) | C++17 | 583 ms | 1076 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// CERC 2012
// Problem B: Who wants to live forever?
// O(n) solution
// Author: Arkadiusz Pawlik
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
bool die(string s) {
s += "0";
int n = s.size();
int l = ((n ^ (n-1)) + 1) / 2;
int cnt = n / l;
for (int i = 1; i < cnt; ++i) {
for (int k = 0; k < l-1; ++k) {
if (s[i*l+k] != s[i*l-2-k]) return false;
}
if (s[i*l-1] != '0') return false;
}
return true;
}
string ft(string s) {
for (int i = 0; i < s.size(); ++i) {
if (i % 3 == 2) continue;
s[i] = (s[i] == '1') ? '0' : '1';
}
return s;
}
int main() {
int n;
cin >> n;
while(n--) {
string s;
cin >> s;
if (die(s)) cout << "DIES" << endl;
else cout << "LIVES" << endl;
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |