結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー treeonetreeone
提出日時 2019-08-30 22:32:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,354 bytes
コンパイル時間 2,429 ms
コンパイル使用メモリ 208,864 KB
実行使用メモリ 8,160 KB
最終ジャッジ日時 2023-09-06 06:59:39
合計ジャッジ時間 5,107 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
6,812 KB
testcase_01 WA -
testcase_02 AC 184 ms
7,956 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
5,456 KB
testcase_06 AC 2 ms
5,512 KB
testcase_07 AC 2 ms
5,384 KB
testcase_08 AC 39 ms
6,184 KB
testcase_09 AC 2 ms
5,520 KB
testcase_10 AC 2 ms
5,552 KB
testcase_11 AC 2 ms
5,560 KB
testcase_12 AC 11 ms
5,760 KB
testcase_13 AC 1 ms
5,408 KB
testcase_14 AC 2 ms
5,412 KB
testcase_15 AC 1 ms
5,448 KB
testcase_16 AC 2 ms
5,664 KB
testcase_17 AC 1 ms
5,472 KB
testcase_18 AC 1 ms
5,664 KB
testcase_19 WA -
testcase_20 AC 2 ms
5,412 KB
testcase_21 AC 2 ms
5,456 KB
testcase_22 AC 2 ms
5,460 KB
testcase_23 AC 2 ms
5,512 KB
testcase_24 AC 2 ms
5,524 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
5,468 KB
testcase_28 AC 2 ms
5,416 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 2 ms
5,616 KB
testcase_32 AC 6 ms
5,600 KB
testcase_33 AC 2 ms
5,432 KB
testcase_34 AC 25 ms
6,184 KB
testcase_35 AC 186 ms
8,108 KB
testcase_36 AC 101 ms
6,960 KB
testcase_37 WA -
testcase_38 AC 195 ms
8,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

int dp[300010], prv[300010];

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 0; i <= n; i++){
        dp[i] = i;
        prv[i] = 1;
    }
    for(int i = 2; i * i <= n; i++){
        for(int j = 0; j <= n - i * i; j++){
            // cout << i << ' ' << j << endl;
            if(dp[j + i * i] > dp[j] + i){
                dp[j + i * i] = dp[j] + i;
                prv[j + i * i] = i;
                // cout << "  " << dp[j + i * i] << endl;
            }
        }
    }
    vector<int> a;
    int now = n;
    while(now != 0){
        a.push_back(prv[now]);
        now = now - prv[now] * prv[now];
    }
    vector<int> odd, even;
    for(auto i : a){
        if(i % 2) odd.push_back(i);
        else even.push_back(i);
    }
    sort(odd.begin(), odd.end());
    sort(even.rbegin(), even.rend());
    a.clear();
    for(auto i : odd) a.push_back(i);
    for(auto i : even) a.push_back(i);
    string ans = "";
    int cnt = 0;
    for(auto i : a){
        rep(j, 0, i){
            ans += (cnt % 2 ? '1' : '0');
            cnt++;
        }
        cnt++;
    }
    cout << ans << endl;
}
0