結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー nebukuro09nebukuro09
提出日時 2019-08-30 21:57:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 802 bytes
コンパイル時間 1,664 ms
コンパイル使用メモリ 164,168 KB
実行使用メモリ 10,588 KB
最終ジャッジ日時 2023-09-06 06:49:45
合計ジャッジ時間 4,251 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
7,448 KB
testcase_06 AC 2 ms
7,676 KB
testcase_07 AC 2 ms
7,444 KB
testcase_08 WA -
testcase_09 AC 3 ms
7,728 KB
testcase_10 AC 3 ms
7,584 KB
testcase_11 AC 3 ms
7,444 KB
testcase_12 AC 10 ms
7,748 KB
testcase_13 AC 3 ms
7,464 KB
testcase_14 AC 3 ms
7,584 KB
testcase_15 AC 2 ms
7,488 KB
testcase_16 AC 3 ms
7,464 KB
testcase_17 AC 2 ms
7,464 KB
testcase_18 AC 2 ms
7,488 KB
testcase_19 AC 3 ms
7,564 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 3 ms
7,428 KB
testcase_24 AC 2 ms
7,432 KB
testcase_25 AC 2 ms
7,440 KB
testcase_26 AC 2 ms
7,432 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 3 ms
7,560 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <vector>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP2(i,m,n) for (int i=m;i<(n);i++)
typedef long long ll;

int N;
ll dp[303030];
ll par[303030];
ll par2[303030];

void solve() {
    cin >> N;
    REP(i, N+1) dp[i] = 1LL << 59;

    dp[0] = 0;

    REP(i, N) for (ll j = 1; i + j * j <= N; ++j) {
        if (dp[i] + j <= dp[i + j * j]) {
            dp[i + j * j] = dp[i] + j;
            par[i + j * j] = i;
            par2[i + j * j] = j;
        }
    }

    int last = 0;
    for (ll i = N; i > 0; ) {
        REP(_, par2[i]) {
            cout << last;
            last ^= 1;
        }
        last ^= 1;
        i = par[i];
    }


    cout << "\n";
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}
0