結果

問題 No.690 E869120 and Constructing Array 4
コンテスト
ユーザー RasShalGul
提出日時 2026-08-24 18:42:10
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.90.0)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,257 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,892 ms
コンパイル使用メモリ 352,512 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-08-24 18:43:11
合計ジャッジ時間 7,262 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#define int long long
using namespace std;
template<typename type>//快读
inline void read(type &x){
	x=0;
	static bool flag(0);
	char ch=getchar();
	while(!isdigit(ch)){
		flag=ch=='-';
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	flag?x=-x:0;
}
template<typename type>//快写
inline void write(type x,bool mode=1){
	x<0?x=-x,putchar('-'):0;
	static short Stack[50],top(0);
	do{
		Stack[++top]=x%10,x/=10;
	}while(x);
	while(top){
		putchar(Stack[top--]|48);
	}
	mode?putchar('\n'):putchar(' ');
}
const int maxn=1e3+5;
int vis[maxn][maxn];
vector<int> a,b;
signed main(){
	//freopen("path.in","r",stdin);
	//freopen("path.out","w",stdout);
	int n;
	read(n);
	int num;
	for(int i=0;;i++){
		if((1ll<<i)>n){
			num=i+1;
			break;
		}
	}
	int v=num+1;
	int e=(v)*(v-1)/(2),d=(1ll<<(num-1))-n;
	if(d==0){
		write(v,0);
		write(e,1);
		for(int i=1;i<v;i++){
			for(int j=i+1;j<=v;j++){
				write(i,0);
				write(j,1);
			}
		}
		return 0;
	}
	for(int i=num;i>=0;i--){
		int p=(1<<i);
		if(d>=p){
			d-=p;
			vis[2+i][v]=1;
			e--;
		}
	}
	write(v,0);
	write(e,1);
	for(int i=1;i<v;i++){
		for(int j=i+1;j<=v;j++){
			if(vis[i][j]==0){
				write(i,0);
				write(j,1);
			}
		}
	}
	return 0;
}
0