답안 #138475

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
138475 2019-07-30T05:07:42 Z 김세빈(#3318) Who wants to live forever? (CERC12_B) C++14
0 / 1
254 ms 760 KB
#include <bits/stdc++.h>

using namespace std;

bool simulate(string &S)
{
	string T;
	int i, s, ret = 0;
	
	for(i=0; i<S.size(); i++){
		s = 0;
		if(i && S[i - 1] == '1') s ++;
		if(i + 1 < S.size() && S[i + 1] == '1') s ++;
		T.push_back("01"[s & 1]);
		if(s & 1) ret = 1;
	}
	
	swap(S, T);
	
	return ret;
}

bool tc()
{
	string S;
	int i;
	
	cin >> S;
	
	for(i=0; i<60; i++){
		if(!simulate(S)) return true;
	}
	
	return false;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int t;
	
	cin >> t;
	
	for(; t--; ){
		cout << (tc()? "DIES" : "LIVES") << "\n";
	}
	
	return 0;
}

Compilation message

B.cpp: In function 'bool simulate(std::__cxx11::string&)':
B.cpp:10:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=0; i<S.size(); i++){
           ~^~~~~~~~~
B.cpp:13:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(i + 1 < S.size() && S[i + 1] == '1') s ++;
      ~~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 254 ms 760 KB Output is correct
4 Incorrect 93 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -