結果

問題 No.630 門松グラフ
ユーザー Kutimoti_TKutimoti_T
提出日時 2018-01-05 22:53:52
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,205 bytes
コンパイル時間 793 ms
コンパイル使用メモリ 70,620 KB
実行使用メモリ 5,992 KB
最終ジャッジ日時 2023-08-24 21:09:54
合計ジャッジ時間 6,985 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <sstream>
using namespace std;

#define FOR(i, s, e) for (int i = (s); i <= (e); i++)

int N;
int M;

int a[100001];

int MAX = 100000;
int MIN = 1;

stringstream result;

int main()
{
    cin >> N >> M;

    for (int i = 1; i <= N; i++)
    {
        if (i % 2 == 1)
        {
            a[i] = MAX;
            MAX--;
        }
        else
        {
            a[i] = MIN;
            MIN++;
        }
        if (i < N - 1)
        {
            result << i << " " << i + 1 << endl;
        }
    }

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

    int remain = M - (N - 1);

    for (int i = 1; i <= N; i++)
    {
        for (int j = i + 3; j <= N; j += 2)
        {
            result << i << " " << j << endl;
            remain--;
            if (remain <= 0)
            {
                cout << "YES" << endl;
                FOR(i,1,N) cout << a[i] << " ";
                cout << endl;
                cout << result.str();
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}
0