結果

問題 No.630 門松グラフ
ユーザー outlineoutline
提出日時 2021-03-12 18:00:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,043 bytes
コンパイル時間 2,901 ms
コンパイル使用メモリ 135,512 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-22 07:31:45
合計ジャッジ時間 5,272 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 3 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 WA -
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 13 ms
6,944 KB
testcase_27 WA -
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 16 ms
6,940 KB
testcase_30 AC 15 ms
6,944 KB
testcase_31 AC 14 ms
6,940 KB
testcase_32 AC 10 ms
6,940 KB
testcase_33 AC 8 ms
6,940 KB
testcase_34 AC 11 ms
6,944 KB
testcase_35 AC 9 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
using namespace std;

using ll = long long;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, M;
    cin >> N >> M;

    if(M < N - 1){
        cout << "NO\n";
        return 0;
    }

    int V = N - (N % 2);
    int E = M - (N % 2);
    if(E > V + (V / 2 - 2) * (V / 2) + (N % 2 == 1 ? V - 1 : 0)){
        cout << "NO\n";
        return 0;
    }

    int x = 1;
    vector<int> a(N);
    if(N % 2 == 1)  a[N - 1] = N;
    for(int i = 0; i < N - 1; i += 2)   a[i] = x++;
    for(int i = N - 1 - (N % 2); i >= 0; i -= 2)    a[i] = x++;

    cout << "YES\n";
    for(int i = 0; i < N; ++i)  cout << a[i] << ' ';
    cout << '\n';
    if(N % 2 == 1)  cout << 1 << ' ' << N << '\n';
    for(int i = 1; i < V; ++i){
        cout << i << ' ' << i + 1 << '\n';
        --E;
    }
    if(E-- > 0) cout << V << ' ' << 1 << '\n';
    int v = 2, u = 5;
    while(E > 0){
        cout << v << ' ' << u << '\n';
        --E;
        if((u += 2) > V)    u %= V;
        if(u == v - 1){
            v += 2;
            u = v + 3;
            if(v == 2)  break;
        }
    }
    while(E > 0){
        cout << N << ' ' << v++ << '\n';
        --E;
    }

    return 0;
}
0