結果
問題 | No.714 回転寿司屋のシミュレート |
ユーザー |
|
提出日時 | 2018-10-30 16:38:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 1,961 bytes |
コンパイル時間 | 1,968 ms |
コンパイル使用メモリ | 202,820 KB |
最終ジャッジ日時 | 2025-01-06 15:09:17 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
ソースコード
#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;}