結果

問題 No.946 箱箱箱
ユーザー %20
提出日時 2019-09-03 07:10:26
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 535 bytes
コンパイル時間 2,136 ms
コンパイル使用メモリ 198,008 KB
最終ジャッジ日時 2025-01-07 16:20:13
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){cin.tie(0);ios::sync_with_stdio(false);
	int N;cin>>N;
	vector<int>A(N),S(N+1),G(N+1);
	S[0]=0;
	for(int i=0;i<N;++i){
		cin>>A[i];
		S[i+1]=S[i]^A[i];
	}
	G[N]=0;
	for(int i=N-1;i>=0;--i){
		vector<int>v;
		for(int j=i+1;j<=N;++j){
			v.push_back(S[i]^S[j]^G[j]);
		}
		sort(v.begin(),v.end());
		G[i]=0;
		for(int e:v){
			if(e==G[i]){
				++G[i];
			}else if(e>G[i]){
				break;
			}
		}
	}
	if(G[0]==0){
		cout<<"Takanashi\n";
	}else{
		cout<<"Takahashi\n";
	}
	return 0;
}
0