답안 #138495

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

using namespace std;

bool tc(string &S)
{
	int n, i, t;
	
	n = S.size();
	t = (n + 1 ^ n) >> 1;
	
	for(i=0; i<n-t; i++){
		if((i & t) == t){
			if(S[i] != '0') return true;
		}
		else if(S[i] != S[i + (t - (i & t)) * 2]) return true;
	}
	
	return false;
}

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

Compilation message

B.cpp: In function 'bool tc(std::__cxx11::string&)':
B.cpp:10:9: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
  t = (n + 1 ^ n) >> 1;
       ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 13 ms 760 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 21 ms 10504 KB Output is correct