結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
7,468 KB
testcase_06 AC 2 ms
7,512 KB
testcase_07 AC 2 ms
7,572 KB
testcase_08 WA -
testcase_09 AC 2 ms
7,488 KB
testcase_10 AC 2 ms
7,516 KB
testcase_11 AC 2 ms
7,456 KB
testcase_12 AC 9 ms
7,824 KB
testcase_13 AC 3 ms
7,528 KB
testcase_14 AC 3 ms
7,436 KB
testcase_15 AC 2 ms
7,432 KB
testcase_16 AC 2 ms
7,444 KB
testcase_17 AC 2 ms
7,520 KB
testcase_18 AC 2 ms
7,488 KB
testcase_19 AC 1 ms
7,468 KB
testcase_20 AC 2 ms
7,472 KB
testcase_21 AC 2 ms
7,468 KB
testcase_22 AC 2 ms
7,504 KB
testcase_23 AC 2 ms
7,552 KB
testcase_24 AC 2 ms
7,444 KB
testcase_25 AC 2 ms
7,504 KB
testcase_26 AC 2 ms
7,492 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 2 ms
7,488 KB
testcase_34 AC 18 ms
8,000 KB
testcase_35 WA -
testcase_36 AC 71 ms
9,056 KB
testcase_37 WA -
testcase_38 AC 146 ms
10,452 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;
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;
        }
    }

    vector<int> odd;
    vector<int> even;

    for (ll i = N; i > 0; ) {
        if (par2[i] % 2 == 0) {
            even.push_back(par2[i]);
        } else {
            odd.push_back(par2[i]);
        }
        i = par[i];
    }

    sort(odd.begin(), odd.end());
        sort(even.begin(), even.end());

    int v = 0;
    for (auto x: odd) {
        REP(_, x) {
            cout << v;
            v ^= 1;
        }
        v ^= 1;
    }
    for (auto x: even) {
        REP(_, x) {
            cout << v;
            v ^= 1;
        }
        v ^= 1;
    }

    cout << "\n";
}

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