結果

問題 No.714 回転寿司屋のシミュレート
ユーザー 0w10w1
提出日時 2018-10-30 16:38:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 1,961 bytes
コンパイル時間 2,461 ms
コンパイル使用メモリ 208,340 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-30 00:44:24
合計ジャッジ時間 3,714 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 5 ms
5,376 KB
testcase_07 AC 7 ms
5,376 KB
testcase_08 AC 9 ms
5,376 KB
testcase_09 AC 5 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 5 ms
5,376 KB
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 4 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 4 ms
5,376 KB
testcase_19 AC 4 ms
5,376 KB
testcase_20 AC 4 ms
5,376 KB
testcase_21 AC 4 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 AC 3 ms
5,376 KB
testcase_26 AC 3 ms
5,376 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 AC 3 ms
5,376 KB
testcase_29 AC 3 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template <typename T>
class Array : public vector<T> {
 public:
  using vector<T>::vector;
  using vector<T>::begin;
  using vector<T>::end;
  using vector<T>::push_back;
  template <typename R>
  Array<R> map(function<R(T)> f) {
    Array<R> res(end() - begin());
    for (auto it = begin(); it != end(); ++it) res[it - begin()] = f(*it);
    return res;
  }
  Array<T> select(function<bool(T)> f) {
    Array<T> res;
    for (auto it = begin(); it != end(); ++it)
      if (f(*it)) res.push_back(*it);
    return res;
  }
  template <typename R>
  R reduce(R u, function<R(R, T)> f) {
    for (auto it = begin(); it != end(); ++it) u = f(u, *it);
    return u;
  }
  template <typename U>
  Array<pair<T, U>> zip(const Array<U> &b) {
    assert(end() - begin() == b.end() - b.begin());
    Array<pair<T, U>> res;
    for (auto it = begin(); it != end(); ++it)
      res.push_back({*it, b[it - begin()]});
    return res;
  }
  Array<T> iota(T st) {
    Array<T> res(end() - begin());
    ::iota(res.begin(), res.end(), st);
    return res;
  }
};

signed main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  Array<Array<string>> tlist(20);
  for (int i = 0; i < N; ++i) {
    int OP;
    cin >> OP;
    if (OP == 0) {
      int n, m;
      cin >> n >> m;
      assert(tlist[n - 1].empty());
      tlist[n - 1].resize(m);
      for (int j = 0; j < m; ++j) cin >> tlist[n - 1][j];
    } else if (OP == 1) {
      string b;
      cin >> b;
      auto it = find_if(tlist.begin(), tlist.end(), [&](Array<string> &a) {
                  auto it = find(a.begin(), a.end(), b);
                  if (it == a.end()) return false;
                  a.erase(it);
                  return true;
                });
      if (it == tlist.end()) cout << -1 << endl;
      else cout << it - tlist.begin() + 1 << endl;
    } else {
      int c;
      cin >> c;
      tlist[c - 1].clear();
    }
  }
  
  return 0;
}
0