結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー okok
提出日時 2019-08-30 23:22:22
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,547 bytes
コンパイル時間 661 ms
コンパイル使用メモリ 79,484 KB
実行使用メモリ 5,348 KB
最終ジャッジ日時 2023-09-06 07:06:24
合計ジャッジ時間 3,419 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 WA -
testcase_02 RE -
testcase_03 RE -
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 3 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 2 ms
4,380 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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];

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;
				}
			}
		}
	}
	
	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(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;
}
0