結果
| 問題 |
No.2372 既視感
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-07 22:19:00 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,662 bytes |
| コンパイル時間 | 2,195 ms |
| コンパイル使用メモリ | 207,880 KB |
| 最終ジャッジ日時 | 2025-02-15 07:41:13 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 WA * 4 |
ソースコード
#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()) {
if (vec.front() == s) {
vec.pop();
} else {
new_vec.push(vec.front()); vec.pop();
}
}
while (!new_vec.empty()) {
vec.push(new_vec.front()); new_vec.pop();
}
vec.push(s);
};
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);
}
}
}