結果
| 問題 |
No.946 箱箱箱
|
| コンテスト | |
| ユーザー |
chocopuu
|
| 提出日時 | 2019-12-09 06:59:30 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,179 bytes |
| コンパイル時間 | 1,789 ms |
| コンパイル使用メモリ | 172,404 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-11 17:31:41 |
| 合計ジャッジ時間 | 3,369 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 WA * 12 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
#define BIT(S,i) ((S&(1ll<<i))>0)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;
int dp[2020][3],N;
int solve(int n,int x,vector<int>&a){
if(dp[n][x]!=-1)return dp[n][x];
int &t = dp[n][x] = 0;
if(x==2){
if(solve(n,1,a)==0)return t = 1;
}
if(x){
return t = (solve(n,0,a)^1);
}
int xors = 0;
FOR(i,n+1,N+1){
xors ^= a[i-1];
if(solve(i,xors,a)==0)t=1;
}
return t;
}
signed main(){
cin>>N;
vector<int>a(N);
REP(i,N)cin>>a[i];
int now = 0,flg = -1;
REP(i,N){
now^=a[i];
if(now==0)flg=i;
}
now=0;
int flg1=0;
if(flg!=N-1){
RREP(i,N){
now^=a[i];
if(now==0)flg1=2;
}
}
if(flg!=-1&&flg1==0)cout<<"Takahashi"<<endl;
else cout<<"Takanashi"<<endl;
}
chocopuu