結果

問題 No.24 数当てゲーム
ユーザー Rumain831
提出日時 2025-05-04 20:49:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 747 bytes
コンパイル時間 803 ms
コンパイル使用メモリ 81,712 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-05-04 20:49:43
合計ジャッジ時間 1,744 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<set>
using namespace std;

int main(void){
  int n; cin >> n;
  set<int> cap, cup;
  for(int i=0; i<10; i++) cup.insert(i);
  for(int i=0; i<n; i++){
    int a[4];
    for(int j=0; j<4; j++) cin >> a[j];
    string r; cin >> r;
    if(r=="NO"){
      for(int j=0; j<4; j++){
        cup.erase(a[j]);
        cap.erase(a[j]);
      }
    }
    else{
      if(cap.size()){
        set<int> newcap;
        for(int j=0; j<4; j++){
          if(cap.count(a[j])) newcap.insert(a[j]);
        }
        swap(cap, newcap);
      }
      else if(cap.empty()) for(int j=0; j<4; j++) cap.insert(a[j]);
    }
  }
  if(cap.size()==1) cout << *cap.begin() << endl;
  else cout << *cup.begin() << endl;
  return 0;
}
0