結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー lowrlowr
提出日時 2019-08-31 16:31:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,215 bytes
コンパイル時間 2,267 ms
コンパイル使用メモリ 209,264 KB
実行使用メモリ 20,864 KB
最終ジャッジ日時 2023-09-06 11:58:18
合計ジャッジ時間 8,029 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 123 ms
9,196 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 31 ms
5,396 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
4,384 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 16 ms
4,688 KB
testcase_33 AC 4 ms
4,376 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 321 ms
14,376 KB
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<std::vector<int>> t(n + 1);
    std::vector<int> s(n + 1, 1000000);
    for (int i = 1; i * i <= n; i++) {
        t[i * i].push_back(i);
        s[i * i] = i;
    }
    for (int i = 1; i <= 4; i++) {
        for (int j = 1; j <= n; j++) {
            if (t[j].size() == i) {
                for (int k = 1; j + k * k <= n; k++) {
                    int index = j + k * k;
                    if (!t[index].empty() && t[index].size() <= i) continue;
                    if (s[j] + k >= s[index]) continue;
                    t[index] = t[j];
                    t[index].push_back(k);
                    s[index] = s[j] + k;
                }
            }
        }
    }

    auto &v = t[n];
    std::sort(v.begin(), v.end());

    std::string ret(100000, '1');
    do {
        int base = 0;
        std::string c;
        for (auto e : t[n]) {
            for (int i = 0; i < e; i++) c += ((i + base) % 2 ? '1' : '0');
            base = !(e & 1);
        }
        ret = std::min(ret, c);
    } while (std::next_permutation(v.begin(), v.end()));

    std::cout << ret << std::endl;

    return 0;
}
0