結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー nebukuro09nebukuro09
提出日時 2019-08-30 22:30:50
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,062 ms / 2,000 ms
コード長 1,007 bytes
コンパイル時間 2,275 ms
コンパイル使用メモリ 206,120 KB
実行使用メモリ 41,964 KB
最終ジャッジ日時 2023-09-02 07:09:31
合計ジャッジ時間 10,947 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 482 ms
27,376 KB
testcase_01 AC 263 ms
22,328 KB
testcase_02 AC 1,001 ms
40,404 KB
testcase_03 AC 829 ms
35,028 KB
testcase_04 AC 7 ms
15,712 KB
testcase_05 AC 7 ms
15,960 KB
testcase_06 AC 7 ms
15,780 KB
testcase_07 AC 7 ms
15,664 KB
testcase_08 AC 236 ms
21,484 KB
testcase_09 AC 7 ms
15,700 KB
testcase_10 AC 6 ms
15,692 KB
testcase_11 AC 7 ms
15,712 KB
testcase_12 AC 72 ms
17,292 KB
testcase_13 AC 6 ms
15,648 KB
testcase_14 AC 7 ms
15,652 KB
testcase_15 AC 6 ms
15,664 KB
testcase_16 AC 6 ms
15,660 KB
testcase_17 AC 6 ms
15,656 KB
testcase_18 AC 7 ms
15,652 KB
testcase_19 AC 6 ms
15,780 KB
testcase_20 AC 7 ms
15,712 KB
testcase_21 AC 7 ms
15,652 KB
testcase_22 AC 6 ms
15,852 KB
testcase_23 AC 7 ms
15,656 KB
testcase_24 AC 6 ms
15,712 KB
testcase_25 AC 7 ms
15,700 KB
testcase_26 AC 6 ms
15,700 KB
testcase_27 AC 7 ms
15,708 KB
testcase_28 AC 6 ms
15,704 KB
testcase_29 AC 7 ms
15,664 KB
testcase_30 AC 7 ms
15,652 KB
testcase_31 AC 6 ms
15,656 KB
testcase_32 AC 41 ms
16,608 KB
testcase_33 AC 13 ms
16,124 KB
testcase_34 AC 151 ms
19,268 KB
testcase_35 AC 1,062 ms
41,964 KB
testcase_36 AC 562 ms
28,952 KB
testcase_37 AC 1,047 ms
41,764 KB
testcase_38 AC 1,059 ms
41,756 KB
権限があれば一括ダウンロードができます

ソースコード

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;
int dp[303030];
vector<bool> ans[303030];
vector<bool> tmp;

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

    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;
            ans[i + j * j] = ans[i];
            int last = i == 0 ? 0 : ans[i].back();
            REP(_, j) ans[i + j * j].push_back(last), last ^= 1;
        } else if (dp[i] + j == dp[i + j * j]) {
            tmp = ans[i];
            int last = i == 0 ? 0 : ans[i].back();
            REP(_, j) tmp.push_back(last), last ^= 1;
            ans[i + j * j] = min(ans[i + j * j], tmp);
        }
    }

    REP(i, ans[N].size()) cout << ans[N][i] ? 1 : 0;
    cout << "\n";
}

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