結果

問題 No.3126 Dual Query Problem
コンテスト
ユーザー tnakao0123
提出日時 2025-04-28 14:13:00
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 36 ms / 2,000 ms
+ 20µs
コード長 988 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 322 ms
コンパイル使用メモリ 79,976 KB
実行使用メモリ 11,024 KB
最終ジャッジ日時 2026-07-12 11:35:33
合計ジャッジ時間 8,223 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/* -*- 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;
}
0