結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー tko919tko919
提出日時 2019-08-30 23:11:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,561 bytes
コンパイル時間 1,716 ms
コンパイル使用メモリ 175,996 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 07:05:24
合計ジャッジ時間 4,579 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end

vector<vector<int>> sq;int n,d,rt;
void init(){
    int mi=inf;
    rep(i,0,550)rep(j,i,550)rep(k,j,550){
        d=n-i*i-j*j-k*k;
        if(d<0)continue;
        rt=sqrt(d);
        if(rt*rt==d&&(mi==i+j+k+rt||chmin(mi,i+j+k+rt))){
            sq.push_back({i,j,k,rt});
        }
    }
}

int main(){
    scanf("%d",&n); init();
    int mi=inf;
    rep(i,0,sq.size())chmin(mi,sq[i][0]+sq[i][1]+sq[i][2]+sq[i][3]);
    rep(i,0,sq.size())sort(ALL(sq[i]));
    string ans;
    rep(j,0,sq.size())if(accumulate(ALL(sq[j]),0)==mi){
        do{
            string sub; char c='0';
            rep(rot,0,4)rep(i,0,sq[j][rot]){
                if(i){
                    if(c=='0')c='1';
                    else c='0';
                }
                sub+=c;
            }
            if(ans=="")ans=sub;
            else chmin(ans,sub);
        } while (next_permutation(ALL(sq[j])));
    }
    cout<<ans<<endl;
    return 0;
}
0