結果
問題 |
No.630 門松グラフ
|
ユーザー |
![]() |
提出日時 | 2018-01-06 16:48:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 141 ms / 1,500 ms |
コード長 | 1,661 bytes |
コンパイル時間 | 1,481 ms |
コンパイル使用メモリ | 171,744 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 08:38:50 |
合計ジャッジ時間 | 4,967 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#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; }