結果
問題 |
No.630 門松グラフ
|
ユーザー |
|
提出日時 | 2025-08-23 17:43:16 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 51 ms / 1,500 ms |
コード長 | 1,812 bytes |
コンパイル時間 | 2,166 ms |
コンパイル使用メモリ | 205,512 KB |
実行使用メモリ | 8,916 KB |
最終ジャッジ日時 | 2025-08-23 17:43:21 |
合計ジャッジ時間 | 4,566 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#include<bits/stdc++.h> #define ls(k) k << 1 #define rs(k) k << 1 | 1 #define fi first #define se second #define add(x, y) ((x + y >= mod) ? (x + y - mod) : (x + y)) #define dec(x, y) ((x - y < 0) ? (x - y + mod) : (x - y)) #define popcnt(x) __builtin_popcount(x) #define open(s1, s2) freopen(s1, "r", stdin), freopen(s2, "w", stdout); using namespace std; typedef __int128 __; typedef long double lb; typedef double db; typedef unsigned long long ull; typedef long long ll; bool Begin; const int N = 1e5 + 10; inline ll read(){ ll x = 0, f = 1; char c = getchar(); while(c < '0' || c > '9'){ if(c == '-') f = -1; c = getchar(); } while(c >= '0' && c <= '9'){ x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } return x * f; } inline void write(ll x){ if(x < 0){ putchar('-'); x = -x; } if(x > 9) write(x / 10); putchar(x % 10 + '0'); } int n, m; int a[N]; vector<pair<int, int>> V; set<pair<int, int>> S; bool End; int main(){ n = read(), m = read(); for(int i = 0; i < n; ++i) a[i] = i + 1; for(int i = 0; i < (n >> 1); ++i){ V.push_back({i, i + (n >> 1)}); S.insert({i, i + (n >> 1)}); m--; if(i + (n >> 1) + 1 < n){ V.push_back({i, i + (n >> 1) + 1}); S.insert({i, i + (n >> 1) + 1}); m--; } } if(m < 0){ puts("NO"); return 0; } for(int i = 0; i < (n >> 1); ++i){ for(int j = (n >> 1); j < n && m; ++j){ if(!S.count({i, j})){ V.push_back({i, j}); S.insert({i, j}); m--; } } } if(m){ puts("NO"); return 0; } puts("YES"); for(int i = 0; i < n; ++i){ write(a[i]); putchar(' '); } putchar('\n'); for(auto t : V){ write(t.fi + 1); putchar(' '); write(t.se + 1); putchar('\n'); } //cerr << '\n' << abs(&Begin - &End) / 1048576 << "MB"; return 0; }