結果
問題 | No.1981 [Cherry 4th Tune N] アルゴリズムが破滅する例 |
ユーザー |
👑 ![]() |
提出日時 | 2022-02-13 01:57:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 494 bytes |
コンパイル時間 | 671 ms |
コンパイル使用メモリ | 66,316 KB |
最終ジャッジ日時 | 2025-01-27 22:55:59 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 49 |
ソースコード
#include<iostream> using namespace std; void output_edge(int a, int b){ cout << a << " " << b << "\n"; } int main(){ int N,K; cin >> N >> K; if (N>2*K){ cout << -1 << endl; return 0; } cout << 2*N-K << endl; int p,q; for (int i=1; i<=N-K; i++){ p=2*i-1; q=2*i; output_edge(p,p); output_edge(p,q); output_edge(q,p); } for (int r=2*(N-K)+1; r<=N; r++){ output_edge(r,r); } return 0; }