結果

問題 No.630 門松グラフ
ユーザー kurarrrkurarrr
提出日時 2018-02-22 11:03:30
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 147 ms / 1,500 ms
コード長 1,542 bytes
コンパイル時間 1,299 ms
コンパイル使用メモリ 160,444 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 22:15:43
合計ジャッジ時間 4,388 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define show_table(n, k, table) rep(i,n){ rep(j,k) cout << table[i][j] << " "; cout << endl;}

template<class T> void chmax(T& a,const T& b){a=max(a,b);}
template<class T> void chmin(T& a,const T& b){a=min(a,b);}

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 302;

int main(){
  int N,M; cin >> N >> M;
  int X,Y; X = (N+1)/2; Y = (N)/2;
  if(!(M>=N-1 && M<=X*Y)){
    cout << "NO" << endl;
    return 0;
  }
  int rest = M - (N-1);
  int temp = X+1;
  cout << "YES" << endl;
  rep(i,N){
    if(i%2==1) cout << temp++ <<  " ";
    else cout << i/2+1 << " ";
  }
  cout << "" << endl;
  rep(i,N){
    if(i!=N-1) cout << i+1 << " " << i+2 << endl;
    if(i!=N-1 && rest>0){
      if(i%2==1){
        for(int j=i+3;j<N;j+=2){
          if(rest==0) break;
          if(j==i+1) continue;
          cout << i+1 << " " << j+1 << endl;
          rest--;
        }
      }else{
        for(int j=i+3;j<N;j+=2){
          if(rest==0) break;
          if(j==i+1) continue;
          cout << i+1 << " " << j+1 << endl;
          rest--;
        }

      }
    }
  }
  return 0;
}
0