結果

問題 No.630 門松グラフ
ユーザー moko_freedommoko_freedom
提出日時 2018-01-27 10:15:36
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 188 ms / 1,500 ms
コード長 1,044 bytes
コンパイル時間 1,823 ms
コンパイル使用メモリ 170,212 KB
実行使用メモリ 10,164 KB
最終ジャッジ日時 2024-12-29 06:36:37
合計ジャッジ時間 5,991 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

//-----------------------------------------------------------------------------

int n,m;
vector<P> v;
map<P,bool> mp;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin>>n>>m;
	if(m<n-1) {
		cout<<"NO"<<endl;
		return 0;
	}
	REP(i,n/2) {
		v.pb(P(i,i+n/2)),m--;
		mp[P(i,i+n/2)]=true;
	}
	REP(i,n/2) {
		if(m==0) break;
		FOR(j,n/2,n) {
			if(m==0) break;
			if(!mp[P(i,j)]) {
				v.pb(P(i,j)),m--;
				mp[P(i,j)]=true;
			}
		}
	}
	if(m!=0) {
		cout<<"NO"<<endl;
		return 0;
	}
	cout<<"YES"<<endl;
	REP(i,n) cout<<i+1<<(i==n-1?'\n':' ');
	for(auto x:v) cout<<x.fi+1<<' '<<x.se+1<<endl;

	return 0;
}
0