結果

問題 No.630 門松グラフ
ユーザー btkbtk
提出日時 2018-01-06 16:48:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 155 ms / 1,500 ms
コード長 1,661 bytes
コンパイル時間 1,565 ms
コンパイル使用メモリ 169,028 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-24 22:18:28
合計ジャッジ時間 5,785 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,384 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 152 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 155 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 143 ms
4,376 KB
testcase_25 AC 1 ms
4,384 KB
testcase_26 AC 142 ms
4,376 KB
testcase_27 AC 141 ms
4,376 KB
testcase_28 AC 148 ms
4,380 KB
testcase_29 AC 133 ms
4,380 KB
testcase_30 AC 147 ms
4,380 KB
testcase_31 AC 131 ms
4,376 KB
testcase_32 AC 71 ms
4,380 KB
testcase_33 AC 69 ms
4,380 KB
testcase_34 AC 106 ms
4,380 KB
testcase_35 AC 81 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifndef VS
#include<bits/stdc++.h>
#endif

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(0)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int main() {
	int N, M;
	cin >> N >> M;
	int s = N / 2;
	int t = N - s;
	vector<int> a;
	vector<int> b;
	if (M < N - 1 || s*(LL)t < M) {
		cout << "NO" << endl;
		return 0;
	}
	else cout << "YES" << endl;
	for (auto i : range(0, s))a.push_back(i + 1);
	for (auto i : range(s, N))b.push_back(i + 1);
	for (auto i : range(N))cout << " " + (!i) << i + 1; cout << endl;
	for (auto i : range(s)) {
		cout << a[i] << " " << b[i] << endl;
		M--;
	}
	for (auto i : range(s)) if(i+1<t){
		cout << a[i] << " " << b[i+1] << endl;
		M--;
	}
	for(auto i:range(s)){
		if (M <= 0)return 0;;
		for (auto j : range(t)) {
			if (M <= 0)return 0;
			if (i == j)continue;
			if (i + 1 == j)continue;
			cout << a[i] << " " << b[j] << endl;
			M--;
		}
	}

	return 0;
}
0