結果
問題 | No.1355 AND OR GAME |
ユーザー | kotatsugame |
提出日時 | 2021-01-17 14:31:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 155 ms / 2,000 ms |
コード長 | 499 bytes |
コンパイル時間 | 601 ms |
コンパイル使用メモリ | 64,128 KB |
実行使用メモリ | 5,888 KB |
最終ジャッジ日時 | 2024-11-29 15:54:13 |
合計ジャッジ時間 | 13,670 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 95 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 6 | main() | ^~~~
ソースコード
#include<iostream> using namespace std; int N; long X,Y,A[2<<17]; int P[2<<17]; main() { cin>>N>>A[0]>>Y; for(int i=1;i<=N;i++) { cin>>A[i]; P[i]=3; } long x=Y,y=0; for(int i=N;i>=0;i--) { if(A[i]&~(x|y)) { if(x&~A[i]) { cout<<-1<<endl; return 0; } P[i]=1; y|=~A[i]; } else { P[i]=2; x&=~A[i]; y|=A[i]; if(x==0) { P[i]=3; break; } } } if(x!=0)cout<<-1<<endl; else { for(int i=1;i<=N;i++)cout<<P[i]<<(i==N?"\n":" "); } }