結果
問題 |
No.3126 Dual Query Problem
|
ユーザー |
|
提出日時 | 2025-04-25 22:05:58 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 133 ms / 2,000 ms |
コード長 | 869 bytes |
コンパイル時間 | 2,096 ms |
コンパイル使用メモリ | 203,760 KB |
実行使用メモリ | 12,484 KB |
最終ジャッジ日時 | 2025-06-20 02:45:01 |
合計ジャッジ時間 | 12,772 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:19:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 19 | scanf("%d", w + i); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef pair<int, pii> piii; typedef long long ll; const int N = 2000086, MOD = 1e9 + 7, INF = 0x3f3f3f3f; ll res; int n, m, cnt, w[N]; int main() { cin >> n >> m; int idx = 1; map<int, int> ma; vector<piii> ans; for (int i = 1; i < n + 1; i++) { scanf("%d", w + i); if (ma.count(w[i])) ans.push_back({2, {ma[w[i]], 0}}); else ans.push_back({1, {idx, w[i]}}), ma[w[i]] = idx, ans.push_back({2, {ma[w[i]], 0}}), idx++; } while (ans.size() < m) ans.push_back({1, {1, 1}}); if (ans.size() == m) { puts("Yes"); for (auto u : ans) { if (u.first == 1) printf("%d %d %d\n", 1, u.second.first, u.second.second); else printf("%d %d\n", 2, u.second.first); } } else puts("No"); return 0; }