結果

問題 No.2038 Strange Arrange
ユーザー shauuebbitshauuebbit
提出日時 2022-09-07 20:36:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 466 bytes
コンパイル時間 2,004 ms
コンパイル使用メモリ 199,500 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-15 01:11:35
合計ジャッジ時間 2,450 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

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

    vector X(N + 1, 0);

    X[1] = 1;

    for (int i = 2; i <= N; i++) {
        int m = 0;
        for (int j = 1; j < i - j; j++) {
            if (X[j] == X[i - j]) {
                m = max(X[j], m);
            }
        }
        X[i] = m + 1;
        if (X[i - 1] == X[i]) ++X[i];
    }

    for (int i = 1; i <= N; i++) cout << X[i];
    cout << endl;

    return 0;
}
0