結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー tactac
提出日時 2019-09-01 17:09:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,548 bytes
コンパイル時間 1,669 ms
コンパイル使用メモリ 168,180 KB
実行使用メモリ 6,088 KB
最終ジャッジ日時 2023-09-06 12:00:34
合計ジャッジ時間 4,228 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 3 ms
5,668 KB
testcase_07 AC 3 ms
5,700 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 3 ms
5,700 KB
testcase_12 AC 12 ms
5,640 KB
testcase_13 AC 4 ms
5,816 KB
testcase_14 AC 4 ms
5,868 KB
testcase_15 AC 3 ms
5,644 KB
testcase_16 AC 3 ms
5,812 KB
testcase_17 AC 3 ms
5,708 KB
testcase_18 AC 4 ms
5,700 KB
testcase_19 AC 2 ms
5,664 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 3 ms
5,748 KB
testcase_24 AC 3 ms
5,940 KB
testcase_25 AC 3 ms
5,732 KB
testcase_26 AC 3 ms
5,716 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 4 ms
5,816 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

int main() {
    int n;
    cin >> n;
    
    const int MAX_N = 300001;
    int dp[MAX_N];
    rep(i, MAX_N) dp[i] = inf;
    dp[0] = 0;
    dp[1] = 1;
    
    int from[MAX_N];
    fill_n(from, MAX_N, -1);
    
    rep3(i, 2, n + 1) for (int j = 1; j * j <= i; ++j) {
        if (dp[i] > dp[i - j * j] + j) {
            dp[i] = dp[i - j * j] + j;
            from[i] = j * j;
        }
    }
    // rep(i, n + 1) cout << dp[i] << " "; cout << endl;
    // rep(i, n + 1) cout << from[i] << " "; cout << endl;
    
    int now = n;
    vector<int> v;
    v.eb(sqrt(from[now]));
    
    while (1) {
        now -= from[now];
        if (from[now] == -1) break;
        v.eb(sqrt(from[now]));
    }
    
    // rep(i, sz(v)) cout << v[i] << " "; cout << endl;
    
    string str;
    rep(i, sz(v)) {
        int now = (sz(str) ? str.back() - '0' : 0);
        rep(j, v[i]) {
            str += '0' + now;
            now ^= 1;
        }
    }
    
    cout << str << endl;
}
0