結果
問題 |
No.3126 Dual Query Problem
|
ユーザー |
|
提出日時 | 2025-04-25 21:37:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 129 ms / 2,000 ms |
コード長 | 883 bytes |
コンパイル時間 | 2,244 ms |
コンパイル使用メモリ | 206,608 KB |
実行使用メモリ | 15,164 KB |
最終ジャッジ日時 | 2025-06-20 02:41:15 |
合計ジャッジ時間 | 12,328 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) void solve() { ll n, q; cin >> n >> q; map<ll, ll> mp; vector<tuple<ll, ll, ll>> ans; ll p = 1; rep(i, n) { ll x; cin >> x; if (mp.count(x) == 1) { ans.emplace_back(2, mp[x], -1); } else { mp[x] = p; ans.emplace_back(1, p, x); ans.emplace_back(2, p, -1); p++; } } if (q < ll(ans.size())) { cout << "No\n"; return; } while (ll(ans.size()) < q) { ans.emplace_back(1, p, 1); } cout << "Yes\n"; for (const auto &[t, p, x] : ans) { cout << t << ' ' << p; if (t == 1) cout << ' ' << x; cout << '\n'; } } int main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); int T = 1; for (int t = 0; t < T; t++) { solve(); } return 0; }