結果

問題 No.3126 Dual Query Problem
ユーザー InTheBloom
提出日時 2025-04-25 21:35:24
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 866 bytes
コンパイル時間 4,208 ms
コンパイル使用メモリ 203,236 KB
実行使用メモリ 10,340 KB
最終ジャッジ日時 2025-04-25 21:36:10
合計ジャッジ時間 14,408 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 18 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main () {
    int N, Q;
    readln.read(N, Q);
    auto X = new int[](N);
    foreach (i; 0 .. N) {
        X[i] = readln.chomp.to!int;
    }

    auto Y = X.dup;
    Y = Y.sort.uniq.array;

    if (Q <= Y.length + N) {
        writeln("No");
        return;
    }

    writeln("Yes");
    int[int] idof;
    int xi = 0;
    foreach (i; 0 .. Q) {
        if (i < Y.length) {
            writefln("1 %s %s", i + 2, Y[i]);
            idof[Y[i]] = i + 2;
            continue;
        }

        if (xi < N) {
            writefln("2 %s", idof[X[xi]]);
            xi++;
            continue;
        }

        writefln("1 %s %s", 1, 0);
    }
}

void read (T...) (string S, ref T args) {
    import std.conv : to;
    import std.array : split;
    auto buf = S.split;
    foreach (i, ref arg; args) {
        arg = buf[i].to!(typeof(arg));
    }
}
0