結果

問題 No.3126 Dual Query Problem
ユーザー sai
提出日時 2025-04-25 22:46:12
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 835 bytes
コンパイル時間 2,993 ms
コンパイル使用メモリ 286,164 KB
実行使用メモリ 9,448 KB
最終ジャッジ日時 2025-06-20 02:47:19
合計ジャッジ時間 12,146 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, q;
  std::cin >> n >> q;
  std::vector<std::pair<int, int>> ans;
  std::map<int, int> Mp;
  int idx = 1;
  for (int i = 0; i < n; i++) {
    int x;
    std::cin >> x;
    if (x == 0) {
      ans.emplace_back(0, -1);
    } else {
      if (!Mp.count(x)) {
        ans.emplace_back(idx, x);
        Mp[x] = idx;
        idx++;
        q--;
      }
      ans.emplace_back(Mp[x], -1);
    }
    q--;
  }
  if (q >= 0) {
    std::cout << "Yes\n";
    for (;q--;) {
      ans.emplace_back(0, 1);
    }
    for (auto [p, x] : ans) {
      if (x == -1) {
        std::cout << 2 << ' ' << p + 1 << '\n';
      } else {
        std::cout << 1 << ' ' << p + 1 << ' ' << x << '\n';
      }
    }
  } else {
    std::cout << "No\n";
  }
}
0