結果

問題 No.3126 Dual Query Problem
ユーザー startcpp
提出日時 2025-04-25 22:11:30
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 395 ms / 2,000 ms
コード長 738 bytes
コンパイル時間 1,030 ms
コンパイル使用メモリ 77,756 KB
実行使用メモリ 8,620 KB
最終ジャッジ日時 2025-06-20 02:45:32
合計ジャッジ時間 14,373 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

// 値の種類数 回だけクエリ1が必要。余ったらテキトーにブラブラする。
#include <iostream>
#include <vector>
#include <map>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, q;
int X[200000];
map<int, int> mp;
vector<int> xs;

int main() {
	int i;

	cin >> n >>  q;
	rep(i, n) {
		cin >> X[i];
		if (mp.find(X[i]) == mp.end()) {
			mp[X[i]] = mp.size();
			xs.push_back(X[i]);
		}
	}

	if (mp.size() + n > q) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
	rep(i, xs.size()) {
		cout << 1 << " " << 1 + i << " " << xs[i] << endl;
	}
	rep(i, n) {
		cout << 2 << " " << mp[X[i]] + 1 << endl;
	}
	rep(i, q - n - (int)mp.size()) {
		cout << "1 1 1" << endl;
	}
	
	return 0;
}
0