結果

問題 No.3126 Dual Query Problem
ユーザー InTheBloom
提出日時 2025-04-25 21:38:49
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 866 bytes
コンパイル時間 3,984 ms
コンパイル使用メモリ 206,860 KB
実行使用メモリ 8,604 KB
最終ジャッジ日時 2025-06-20 02:41:42
合計ジャッジ時間 15,315 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

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, 1);
    }
}

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