結果

問題 No.630 門松グラフ
ユーザー Kutimoti_TKutimoti_T
提出日時 2018-01-05 23:12:31
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,394 bytes
コンパイル時間 815 ms
コンパイル使用メモリ 71,328 KB
実行使用メモリ 270,404 KB
最終ジャッジ日時 2023-08-24 21:15:48
合計ジャッジ時間 6,073 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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" << endl;
        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;
            M--;
        }
    }
    

    if (M == 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)
        {
            result << i << " " << j << endl;
            if (M == 0)
            {
                cout << "YES" << endl;
M--;
                FOR(i, 1, N)
                    cout << a[i] << " ";
                cout << endl;
                cout << result.str();
                return 0;
            }
            
        }
    }
    cout << "NO" << endl;
    return 0;
}
0