結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー tko919tko919
提出日時 2019-08-30 22:58:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,388 bytes
コンパイル時間 1,900 ms
コンパイル使用メモリ 176,360 KB
実行使用メモリ 14,912 KB
最終ジャッジ日時 2023-09-06 07:03:56
合計ジャッジ時間 8,361 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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,0,550)rep(k,0,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();
    rep(i,0,sq.size())sort(ALL(sq[i]));
    string ans;
    rep(j,0,sq.size()){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)));
    }
    cout<<ans<<endl;
    return 0;
}
0