結果

問題 No.3126 Dual Query Problem
ユーザー ケネン
提出日時 2025-04-25 22:31:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 707 bytes
コンパイル時間 2,323 ms
コンパイル使用メモリ 206,148 KB
実行使用メモリ 12,908 KB
最終ジャッジ日時 2025-06-20 02:46:27
合計ジャッジ時間 10,572 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;

int pi = 1;
map<int, int> m;
vector<int> v;
set<int> s;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);

  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
    s.insert(x);
  }

  if (s.size()+n <= q) {
    cout << "Yes\n";
  } else {
    cout << "No";
    return 0;
  }

  for (int i = 0; i < n; i++) {
    int x = v[i];
    if (!m.count(x)) {
      cout << "1 " << pi << " " << x << "\n";
      m[x] = pi++;
      q--;
    }
    cout << "2 " << m[x] << "\n";
    q--;
  }

  while (q--) cout << "1 1 1\n";
}
0