結果

問題 No.714 回転寿司屋のシミュレート
ユーザー m-44m-44
提出日時 2019-09-22 20:00:35
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 870 bytes
コンパイル時間 2,971 ms
コンパイル使用メモリ 175,896 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-19 03:43:14
合計ジャッジ時間 2,890 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin>>n;
  map<string, int> c[20];
  for (int i=0; i<n; i++) {
    int d;
    cin>>d;
    if (d == 0) {
      int ni, mi;
      cin>>ni>>mi;
      --ni;
      for (int j=0; j<mi; j++) {
        string a;
        cin>>a;
        ++c[ni][a];
      }
    } else if (d == 1) {
      string b;
      cin>>b;
      bool ok = false;
      for (int j=0; j<20; j++) {
        ok = false;
        for (auto d: c[j]) {
          if (d.first == b) {
            if (d.second > 0) {
              cout<<j+1<<endl;
              --c[j][d.first];
              ok = true;
            }
            break;
          }
        }
        if (ok) {
          break;
        }
      }
      if (!ok) {
        cout<<-1<<endl;
      }
    } else {
      int ci;
      cin>>ci;
      --ci;
      c[ci].clear();
    }
  }
}
0