結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 9 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 2 ms
4,380 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;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P, P> PP;
constexpr ll MOD = ll(1e9 + 7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()


int main() {
    ll n;
    cin >> n;
    vector<ll> dp(n+1, IINF), pre(n+1);
    dp[0] = 0;
    for(int i=0;i<n;i++){
        for(int j=1;i+j*j<=n;j++){
            if(dp[i+j*j] > dp[i] + j){
                dp[i+j*j] = dp[i]+j;
                pre[i+j*j] = j;
            }
        }
    }
    vector<ll> len;
    for(int i=n; i>0; i-=pre[i]*pre[i]){
        len.push_back(pre[i]);
    }
    sort(len.begin(), len.end());
    string ans = "";
    int b = 0;
    for(auto l : len){
        for(int i=0;i<l;i++){
            ans.push_back(char('0'+(i+b)%2));
        }
        b ^= (l&1)^1;
    }
    cout << ans << endl;
    return 0;
}
0