結果
問題 | No.2372 既視感 |
ユーザー |
|
提出日時 | 2023-07-07 22:30:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 77 ms / 2,000 ms |
コード長 | 1,627 bytes |
コンパイル時間 | 2,368 ms |
コンパイル使用メモリ | 207,384 KB |
最終ジャッジ日時 | 2025-02-15 07:50:05 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <bits/stdc++.h> using namespace std; struct QueryType { int query_case; vector<pair<string, int>> vec; string s; }; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k, q; cin >> n >> k >> q; vector<QueryType> query(q); for (int i=0;i<q;++i) { cin >> query[i].query_case; if (query[i].query_case == 1) { string s; cin >> s; query[i].s = s; } else { vector<pair<string, int>> vec(6); for (int j=0;j<6;++j) cin >> vec[j].first >> vec[j].second; query[i].vec = vec; } } queue<string> vec; auto check = [&](const string& s) { queue<string> new_vec; bool is_find {false}; while (!vec.empty()) { if (vec.front() == s) is_find = true; new_vec.push(vec.front()); vec.pop(); } while (!new_vec.empty()) { vec.push(new_vec.front()); new_vec.pop(); } return is_find; }; auto add = [&](const string& s) { queue<string> new_vec; while (!vec.empty()) { new_vec.push(vec.front()); vec.pop(); } while (!new_vec.empty()) { vec.push(new_vec.front()); new_vec.pop(); } vec.push(s); while (vec.size() > n) vec.pop(); }; int left {}, right {-1}; for (int i=0;i<q;++i) { if (query[i].query_case == 1) { add(query[i].s); } else { int cnt {}; int ans {}; for (const auto& e : query[i].vec) { if (check(e.first)) ans += min(e.second, k); else ans += e.second; if (60 < ans) break; ++cnt; } cout << cnt << '\n'; for (int j=0;j<cnt;++j) add(query[i].vec[j].first); } } }