結果
| 問題 |
No.873 バイナリ、ヤバいなり!w
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-08-30 23:26:35 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,684 bytes |
| コンパイル時間 | 949 ms |
| コンパイル使用メモリ | 79,288 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-24 01:46:29 |
| 合計ジャッジ時間 | 3,237 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 15 RE * 7 |
ソースコード
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
#define int long long
#define endl "\n"
const long long INF = (long long)1e18;
// const long long MOD = 1'000'000'007;
string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}
const int MAX = 110000;
int hoge[MAX];
int fuga[MAX];
int temp[MAX];
void print(int x, int y){
for(int i = 0; i < x; i++, y = !y){
cout<<y;
}
}
signed main(){
// cin.tie(0);
// ios::sync_with_stdio(false);
// cout<<fixed<<setprecision(10);
int N;
vector<int> ans, ans1, ans0;
cin>>N;
for(int i = 1; i < MAX; i++){
hoge[i] = INF;
}
for(int i = 1; i*i <= N; i++){
for(int j = 0; j <= N; j++){// cout<<i<<" <> "<<j<<endl;
if(j + i*i <= N){
if(hoge[j] + 1 < hoge[j+i*i]){
hoge[j+i*i] = hoge[j] + 1;
fuga[j+i*i] = j;
temp[j+i*i] = i;
}
}
}
}
for(int i = N, b = -1;; i = fuga[i]){
if(b != -1){
ans.push_back(b-i);
// if((b-i)%2) ans1.push_back((int)sqrt(b-i));
// else ans0.push_back((int)sqrt(b-i));
}
if(i){
if(temp[i]%2) ans1.push_back(temp[i]);
else ans0.push_back(temp[i]);
}
// if(b != -1)cout<<i<<" "<<b-i<<endl;
b = i;
if(!i) break;
}
int now = 0;
sort(ans1.begin(), ans1.end());
sort(ans0.begin(), ans0.end());
for(int i = 0, j = 0, k = 0; i < ans.size(); i++){
if(now == 0){
if(j < ans1.size()){
print(ans1[j++], now);
} else {
print(ans0[k++], now);
now = 1;
}
} else {
if(k < ans0.size()){
print(ans0[k++], now);
now = 0;
} else {
print(ans1[j++], now);
}
}
}
cout<<endl;
return 0;
}