結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー T1610T1610
提出日時 2020-07-29 15:27:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,348 bytes
コンパイル時間 2,314 ms
コンパイル使用メモリ 209,100 KB
実行使用メモリ 6,728 KB
最終ジャッジ日時 2023-09-11 07:41:40
合計ジャッジ時間 6,288 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 33 ms
4,472 KB
testcase_02 AC 140 ms
6,536 KB
testcase_03 AC 113 ms
5,892 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 29 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 9 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 5 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 19 ms
4,380 KB
testcase_35 AC 146 ms
6,540 KB
testcase_36 AC 75 ms
5,204 KB
testcase_37 AC 148 ms
6,728 KB
testcase_38 AC 148 ms
6,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}


// #define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << " "
#define dumpL(x) cout << #x << " : " << x << '\n'
#define LINE cout << "line : " << __LINE__ << " "
#define LINEL cout << "line : " << __LINE__ << '\n'
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << " "
#define dumpVL(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) 
#define dumpL(x) 
#define LINE 
#define LINEL 
#define dumpV(v) 
#define dumpVL(v) 
#define STOP assert(false)
#endif
#define mp make_pair
 
namespace std {
template<class S, class T>
ostream &operator <<(ostream& out, const pair<S, T>& a) {
    out << '(' << a.fi << ", " << a.se << ')';
    return out;
}
}

vi calc(int n) {
    vi dp(n+10, 1e9);
    dp[0] = 0;
    using P = pair<int, int>;
    vector<P> tmp(dp.size());
    rep(i, dp.size()) {
        for(int j = 1; j*j+i < (int)dp.size(); ++j) {
            if(dp[i+j*j] >= dp[i] + j) {
                dp[i+j*j] = dp[i] + j;
                tmp[i+j*j] = {i, j};
            }
        }
    }
    vi ret;
    int cur = n;
    while(cur > 0) {
        ret.emplace_back(tmp[cur].second);
        cur = tmp[cur].first;
    }
    return ret;
}


int main(){
    int n;
    cin >> n;
    auto v = calc(n);
    sort(all(v));
    dumpVL(v);
    string str;
    while((int)str.size() < v.back()+10) {
        char c = ('0' + (str.size()%2));
        str += c;
    }
    string ans;
    do {
        string tmp;
        for(auto&& sz: v) {
            tmp += str.substr((tmp.empty()||tmp.back() == '0') ? 0 : 1, sz);
        }
        if(ans.empty()) ans = tmp;
        chmin(ans, tmp);
    }while(next_permutation(all(v)));
    cout << ans << '\n';
    return 0;
}
0