結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー milanis48663220milanis48663220
提出日時 2020-06-11 22:51:28
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,042 bytes
コンパイル時間 768 ms
コンパイル使用メモリ 86,136 KB
実行使用メモリ 4,768 KB
最終ジャッジ日時 2023-09-06 08:45:36
合計ジャッジ時間 3,211 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 160 ms
4,768 KB
testcase_03 AC 128 ms
4,384 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 30 ms
4,384 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 8 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 5 ms
4,376 KB
testcase_33 AC 3 ms
4,376 KB
testcase_34 AC 18 ms
4,376 KB
testcase_35 AC 167 ms
4,532 KB
testcase_36 AC 82 ms
4,376 KB
testcase_37 AC 166 ms
4,456 KB
testcase_38 AC 166 ms
4,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int N;
int d[300001];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 1; i <= N; i++) d[i] = 1e7;
    for(int i = 0; i < N; i++){
        for(int j = 1; i+j*j <= N; j++){
            d[i+j*j] = min(d[i]+j, d[i+j*j]);
        }
    }
    int cur = N;
    vector<int> v, u;
    for(int i = 1; i*i <= N; i +=2 ) v.push_back(i);
    for(int i = 2; i*i <= N; i += 2) u.push_back(i);
    for (auto itr = rbegin(u); itr != rend(u); itr++) v.push_back(*itr);
    int tmp = 0;
    for(int i : v){
        while(true){
            if(cur == 0) break;
            if(cur-i*i < 0) break;
            if(d[cur-i*i]+i != d[cur]) break;
            cur -= i*i;
            for(int j = 0; j < i; j++) cout << (char)('0'+(tmp^(j%2)));
            if(i%2 == 0) tmp ^= 1;
        }
    }
    cout << endl;
}
0