結果

問題 No.630 門松グラフ
ユーザー bachoppibachoppi
提出日時 2020-12-10 15:56:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 184 ms / 1,500 ms
コード長 1,238 bytes
コンパイル時間 1,207 ms
コンパイル使用メモリ 127,744 KB
実行使用メモリ 13,536 KB
最終ジャッジ日時 2023-10-20 00:45:54
合計ジャッジ時間 5,873 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,460 KB
testcase_01 AC 4 ms
8,408 KB
testcase_02 AC 4 ms
8,412 KB
testcase_03 AC 4 ms
8,464 KB
testcase_04 AC 4 ms
8,460 KB
testcase_05 AC 3 ms
8,408 KB
testcase_06 AC 5 ms
8,408 KB
testcase_07 AC 3 ms
8,460 KB
testcase_08 AC 4 ms
8,460 KB
testcase_09 AC 4 ms
8,408 KB
testcase_10 AC 4 ms
8,408 KB
testcase_11 AC 4 ms
8,460 KB
testcase_12 AC 4 ms
8,460 KB
testcase_13 AC 3 ms
8,408 KB
testcase_14 AC 4 ms
8,464 KB
testcase_15 AC 5 ms
8,460 KB
testcase_16 AC 4 ms
8,464 KB
testcase_17 AC 3 ms
8,464 KB
testcase_18 AC 4 ms
8,464 KB
testcase_19 AC 3 ms
8,464 KB
testcase_20 AC 184 ms
13,536 KB
testcase_21 AC 3 ms
8,408 KB
testcase_22 AC 183 ms
13,536 KB
testcase_23 AC 4 ms
8,408 KB
testcase_24 AC 174 ms
13,148 KB
testcase_25 AC 32 ms
13,092 KB
testcase_26 AC 170 ms
13,148 KB
testcase_27 AC 174 ms
13,144 KB
testcase_28 AC 177 ms
13,380 KB
testcase_29 AC 157 ms
12,820 KB
testcase_30 AC 177 ms
13,320 KB
testcase_31 AC 159 ms
12,824 KB
testcase_32 AC 85 ms
10,788 KB
testcase_33 AC 86 ms
10,748 KB
testcase_34 AC 129 ms
11,996 KB
testcase_35 AC 97 ms
11,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
long long N;
vector<int> to[200005];
int ki[200005];

  

int main(){
  int n, m; cin >> n >> m; m-=(n-1);
  set<pair<int, int>> ans;
  if(m<0){
    cout << "NO" << endl; return 0;
  }
  for(int i=1; i<=n-1; i++){
    ans.insert({i, i+1});
  }
  if(m>0){
    rep(i, n){
      rep(j, n){
        if(i%2!=j%2 && !ans.count({i+1, j+1}) && i<j){
          ans.insert({i+1, j+1}); m--;
        }
        if(m==0) break;
      }
      if(m==0) break;
    }
  }
  if(m>0){
    cout << "NO" << endl; return 0;
  }
  int a[n];
  rep(i, n){
    if(i%2==0) a[i] = (i/2)+1;
    else a[i] = (n+1)/2 + i/2 + 1;
  }
  cout << "YES" << endl;
  rep(i, n){
    cout << a[i] << " ";
  }
  cout << endl;
  for(auto k: ans){
    cout << k.first << " " << k.second << endl;
  }  
}
0