結果
問題 |
No.2372 既視感
|
ユーザー |
|
提出日時 | 2023-07-07 21:53:34 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,985 bytes |
コンパイル時間 | 2,521 ms |
コンパイル使用メモリ | 217,360 KB |
最終ジャッジ日時 | 2025-02-15 07:11:34 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 16 |
ソースコード
#include <bits/stdc++.h> using namespace std; struct QueryType { int query_type; vector<pair<string, int>> qe; string c; }; 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_type; if (query[i].query_type == 1) { cin >> query[i].c; } else { vector<pair<string, int>> t(6); for (int j=0;j<6;++j) cin >> t[j].first >> t[j].second; query[i].qe = t; } } priority_queue<pair<int, string>, vector<pair<int, string>>, greater<pair<int, string>>> pque; int id {1}; auto check = [&](const string& s) { queue<pair<int, string>> que; bool is_find {false}; while (!pque.empty()) { pair<int, string> ct = pque.top(); pque.pop(); if (ct.second == s) is_find = true; que.push(ct); } while (!que.empty()) { pair<int, string> ct = que.front(); que.pop(); pque.push(ct); } return is_find; }; auto add = [&](const string& s) { queue<pair<int, string>> que; while (!pque.empty()) { pair<int, string> ct = pque.top(); pque.pop(); que.push(ct); } bool is_find {false}; while (!que.empty()) { pair<int, string> ct = que.front(); que.pop(); if (ct.second == s) { is_find = true; ct.first = id++; } pque.push(ct); } if (is_find == false) { pque.push(make_pair(id++, s)); if (pque.size() > n) pque.pop(); } }; for (int i=0;i<q;++i) { if (query[i].query_type == 1) { add(query[i].c); } else { int cnt {}; long long ans {}; for (const auto& e : query[i].qe) { if (check(e.first)) ans += min(e.second, k); else ans += e.second; //cout << ans << ' '; if (ans > 60ll) break; ++cnt; } cout << cnt << '\n'; for (const auto& e : query[i].qe) { add(e.first); } } } }