結果

問題 No.630 門松グラフ
ユーザー tottoripapertottoripaper
提出日時 2018-01-06 01:09:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,366 bytes
コンパイル時間 1,572 ms
コンパイル使用メモリ 172,888 KB
実行使用メモリ 8,428 KB
最終ジャッジ日時 2023-08-24 21:21:35
合計ジャッジ時間 8,125 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

int N, M;
int values[100100];
set<P> edges;

bool can(){
    if(M < N - 1){ // 非連結になってしまう
        return false;
    }

    if(M <= (N / 2) * ((N + 1) / 2)){
        for(int i=1;i<=N;++i){
            values[i] = i;
            edges.emplace(i, i < N ? i + 1 : 1);
        }

        for(int i=1;edges.size()<=M&&i<=N/2;++i){
            for(int j=1;edges.size()<=M&&j<=(N+1)/2;++j){
                edges.emplace(i, N / 2 + j);
            }
        }

        return true;
    }

    // 三角形ができてしまうので残念
    return false;
}

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

    std::cin >> N >> M;

    if(can()){
        std::cout << "YES" << std::endl;
        for(int i=1;i<=N;++i){
            std::cout << values[i] << " \n"[i==N];
        }

        for(const auto& p : edges){
            int u, v;
            tie(u, v) = p;

            std::cout << u << " " << v << std::endl;
        }
    }else{
        std::cout << "NO" << std::endl;
    }
}
0