結果

問題 No.630 門松グラフ
ユーザー Kutimoti_TKutimoti_T
提出日時 2018-01-05 23:09:31
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,406 bytes
コンパイル時間 490 ms
コンパイル使用メモリ 70,872 KB
実行使用メモリ 5,836 KB
最終ジャッジ日時 2023-08-24 21:15:18
合計ジャッジ時間 3,788 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,500 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 WA -
testcase_13 AC 1 ms
4,380 KB
testcase_14 WA -
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 26 ms
5,672 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 26 ms
5,772 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 13 ms
4,552 KB
testcase_25 AC 13 ms
4,380 KB
testcase_26 AC 13 ms
4,800 KB
testcase_27 WA -
testcase_28 AC 25 ms
5,836 KB
testcase_29 AC 21 ms
5,412 KB
testcase_30 AC 20 ms
5,344 KB
testcase_31 AC 17 ms
5,044 KB
testcase_32 AC 11 ms
4,380 KB
testcase_33 AC 8 ms
4,380 KB
testcase_34 AC 14 ms
4,532 KB
testcase_35 AC 9 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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;

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

    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;
        }
    }
    

    int remain = M - (N - 1);

    if (remain <= 0)
    {
        cout << "YES" << endl;
        FOR(i, 1, N)
            cout << a[i] << " ";
        cout << endl;
        cout << result.str();
        return 0;
    }

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