結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー NOSSNOSS
提出日時 2019-08-30 22:28:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,463 bytes
コンパイル時間 1,968 ms
コンパイル使用メモリ 176,532 KB
実行使用メモリ 7,908 KB
最終ジャッジ日時 2023-09-06 06:59:20
合計ジャッジ時間 4,404 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 168 ms
7,460 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 31 ms
4,552 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 9 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 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 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 5 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 19 ms
4,376 KB
testcase_35 AC 173 ms
7,716 KB
testcase_36 AC 85 ms
5,948 KB
testcase_37 AC 171 ms
7,700 KB
testcase_38 AC 172 ms
7,908 KB
権限があれば一括ダウンロードができます

ソースコード

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, ev, od;
    for(int i=n; i>0; i-=pre[i]*pre[i]){
        if(pre[i]%2){
            od.push_back(pre[i]);
        }
        else{
            ev.push_back(pre[i]);
        }
    }
    sort(od.begin(), od.end());
    sort(ev.rbegin(), ev.rend());
    for(auto l : od) len.push_back(l);
    for(auto l : ev) len.push_back(l);
    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