結果

問題 No.3126 Dual Query Problem
ユーザー SnowBeenDiding
提出日時 2025-04-25 21:30:17
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 1,320 bytes
コンパイル時間 5,293 ms
コンパイル使用メモリ 333,320 KB
実行使用メモリ 10,228 KB
最終ジャッジ日時 2025-06-20 02:39:24
合計ジャッジ時間 14,435 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
#include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
using namespace atcoder;
using namespace std;

typedef long long ll;

void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> t, p, x;
    map<int, int> ma;
    int id = 100;
    rep(i, 0, n) {
        int v;
        cin >> v;
        if (v == 0) {
            t.push_back(2);
            p.push_back(1e9);
            x.push_back(0);
        } else if (ma.count(v)) {
            t.push_back(2);
            p.push_back(ma[v]);
            x.push_back(0);
        } else {
            t.push_back(1);
            p.push_back(id);
            x.push_back(v);
            ma[v] = id++;
            t.push_back(2);
            p.push_back(ma[v]);
            x.push_back(0);
        }
    }
    if (t.size() > q) {
        cout << "No\n";
        return;
    }
    while (t.size() < q) {
        t.push_back(1);
        p.push_back(1);
        x.push_back(1);
    }
    cout << "Yes\n";
    rep(i, 0, q) {
        if (t[i] == 1) {
            cout << t[i] << " " << p[i] << " " << x[i] << "\n";
        } else {
            cout << t[i] << " " << p[i] << "\n";
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    while (t--) {
        solve();
    }
}
0