結果

問題 No.1831 Parasol
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2022-02-04 23:44:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,101 bytes
コンパイル時間 798 ms
コンパイル使用メモリ 76,700 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-02 06:09:28
合計ジャッジ時間 3,844 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 2 ms
4,380 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> ans;
    int M = 2 * N - 1;
    for (int i = 0; i < M; i++) {
        ans.push_back(M);
    }
    int now = 0;
    vector<bool> did(2 * N - 1, false), usd(2 * N, false);
    did[0] = true;
    usd[M] = true;
    int cnt = 0;
    for (int i = 1; i < M; i++) {
        int fl = 1;
        while (fl < M && (did[(now + fl) % M] || usd[fl]))
            fl++;
        if (fl == M) {
            if (cnt) {
                return 139;
            }
            fl = 1;
            while (usd[fl]) {
                fl++;
            }
            cnt++;
        }
        //cout << fl << endl;
        for (int j = 0; j < fl; j++) {
            ans.push_back(fl);
        }
        did[(now + fl) % M] = true;
        usd[fl] = true;
        now = (now + fl) % M;
    }
    cout << 2 * N - 1 << endl;
    for (int i = 0; i < 2 * N - 1; i++) {
        for (int j = 0; j < N; j++) {
            cout << ans[i + j * (2 * N - 1)] << (j < N - 1 ? " " : "");
        }
        cout << endl;
    }
}
0