結果

問題 No.714 回転寿司屋のシミュレート
ユーザー 👑 CleyLCleyL
提出日時 2022-09-22 11:12:57
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 762 bytes
コンパイル時間 808 ms
コンパイル使用メモリ 76,008 KB
最終ジャッジ日時 2025-02-07 13:34:21
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int main(){
  vector<string> A[20];
  int n;cin>>n;
  for(int i = 0; n > i; i++){
    int x;cin>>x;
    if(x == 0){
      int a,b;cin>>a>>b;a--;
      for(int j = 0; b > j; j++){
        string s;cin>>s;
        A[a].push_back(s);
      }
    }else if(x == 1){
      string b;cin>>b;
      bool ok = false;
      for(int j = 0; !ok && (20 > j); j++){
        for(int k = 0; !ok && (A[j].size() > k); k++){
          if(A[j][k] == b){
            swap(A[j][k],A[j][A[j].size()-1]);
            A[j].pop_back();
            cout << j+1 << endl;
            ok = true;
          }
        }
      }
      if(!ok)cout << -1 << endl;
    }else{
      int c;cin>>c;
      c--;
      A[c].clear();
    }
  }
}
0