結果
問題 |
No.3126 Dual Query Problem
|
ユーザー |
![]() |
提出日時 | 2025-04-28 14:13:00 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 72 ms / 2,000 ms |
コード長 | 988 bytes |
コンパイル時間 | 814 ms |
コンパイル使用メモリ | 64,896 KB |
実行使用メモリ | 10,576 KB |
最終ジャッジ日時 | 2025-06-20 02:54:30 |
合計ジャッジ時間 | 10,174 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:34:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 34 | scanf("%d%d", &n, &qn); | ~~~~~^~~~~~~~~~~~~~~~~ main.cpp:35:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 35 | for (int i = 0; i < n; i++) scanf("%d", xs + i); | ~~~~~^~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 3126.cc: No.3126 Dual Query Problem - yukicoder */ #include<cstdio> #include<unordered_map> #include<algorithm> #include<tuple> using namespace std; /* constant */ const int MAX_N = 200000; const int MAX_QN = 200000; /* typedef */ using umii = unordered_map<int,int>; using tp3 = tuple<int,int,int>; /* global variables */ int xs[MAX_N]; tp3 ops[MAX_QN + 4]; /* subroutines */ /* main */ int main() { int n, qn; scanf("%d%d", &n, &qn); for (int i = 0; i < n; i++) scanf("%d", xs + i); int m = 0, p = 0; umii xps; for (int i = 0; i < n; i++) { if (! xps.count(xs[i])) { xps[xs[i]] = ++p; ops[m++] = {1, p, xs[i]}; } ops[m++] = {2, xps[xs[i]], -1}; if (m > qn) { puts("No"); return 0; } } while (m < qn) ops[m++] = {1, 1, 1}; puts("Yes"); for (int i = 0; i < qn; i++) { auto [op, p, x] = ops[i]; if (op == 1) printf("1 %d %d\n", p, x); else printf("2 %d\n", p); } return 0; }