結果

問題 No.1519 Diversity
ユーザー 沙耶花沙耶花
提出日時 2021-05-28 21:20:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 827 bytes
コンパイル時間 5,580 ms
コンパイル使用メモリ 263,940 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-07 05:25:58
合計ジャッジ時間 5,136 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001

int main(){
	
	int N;
	cin>>N;
	
	priority_queue<pair<int,int>> Q;
	Q.emplace(1,0);
	Q.emplace(1,1);
	vector<int> a(1,0),b(1,1);
	vector<int> d(N,0);
	d[0] = 1;
	d[1] = 1;
	
	for(int i=2;i<N;i++){
		vector<int> inds;
		while(true){
			pair<int,int> p = Q.top();
			Q.pop();
			if(Q.size()==0 || d[i]+1>Q.top().first+1){
				Q.push(p);
				break;
			}
			inds.push_back(p.second);
			d[i]++;
		}
		rep(j,inds.size()){
			a.push_back(i);
			b.push_back(inds[j]);
			d[inds[j]]++;
			Q.emplace(d[inds[j]],inds[j]);
		}
		Q.emplace(d[i],i);
	}
	
	rep(i,a.size()){
		printf("%d %d\n",a[i]+1,b[i]+1);
	}
	
	return 0;
}
0