結果
| 問題 | No.1355 AND OR GAME | 
| コンテスト | |
| ユーザー |  Nachia | 
| 提出日時 | 2021-01-17 14:59:20 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 61 ms / 2,000 ms | 
| コード長 | 689 bytes | 
| コンパイル時間 | 2,089 ms | 
| コンパイル使用メモリ | 194,780 KB | 
| 最終ジャッジ日時 | 2025-01-18 01:01:53 | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 95 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |   scanf("%d%llu%llu",&N,&X,&Y);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
main.cpp:14:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |   rep(i,N) scanf("%llu",&A[i]);
      |            ~~~~~^~~~~~~~~~~~~~
            
            ソースコード
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)
int N;
ULL X,Y;
ULL A[200000];
vector<int> ans;
int main(){
  scanf("%d%llu%llu",&N,&X,&Y);
  rep(i,N) scanf("%llu",&A[i]);
  ans.assign(N,3);
  ULL mask=(1ull<<60)-1;
  for(int i=N-1; i>=0; i--){
    if((Y&mask)==(A[i]&mask)){ mask=0; break; }
    if(((Y|A[i])&mask)==(A[i]&mask)){ ans[i]=1; mask&=A[i]; continue; }
    if(((Y&A[i])&mask)==(A[i]&mask)){ ans[i]=2; mask&=~A[i]; continue; }
    ans={-1}; break;
  }
  if(mask) if((mask&X)!=(mask&Y)) ans={-1};
  rep(i,ans.size()){ if(i) printf(" "); printf("%d",ans[i]); } printf("\n");
  return 0;
}
            
            
            
        