結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー okok
提出日時 2019-09-01 11:12:16
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,855 bytes
コンパイル時間 813 ms
コンパイル使用メモリ 82,460 KB
実行使用メモリ 6,092 KB
最終ジャッジ日時 2023-09-06 11:59:17
合計ジャッジ時間 3,588 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 WA -
testcase_02 RE -
testcase_03 RE -
testcase_04 WA -
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 3 ms
4,384 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,440 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,504 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 3 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 WA -
testcase_27 AC 2 ms
4,384 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 2 ms
4,384 KB
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>
#include<deque>

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;
				} else if(hoge[i] + 1 == hoge[j+i*i]){
					if(i%2){
						if(temp[j+i*i]%2 && temp[j+i*i] > i){
							fuga[j+i*i] = j;
							temp[j+i*i] = i;
						} else {
						}
					} else {
						if(temp[j+i*i]%2){
							fuga[j+i*i] = j;
							temp[j+i*i] = i;
						} else if(temp[j+i*i] < i){
							fuga[j+i*i] = j;
							temp[j+i*i] = i;
						}
					}
				}
			}
		}
	}
	
	for(int i = N, b = -1;; i = fuga[i]){
		if(i){
			if(temp[i]%2) ans1.push_back(temp[i]);
			else ans0.push_back(temp[i]);
		}
		b = i;
		if(!i) break;
	}
	
	int now = 0;
	sort(ans1.begin(), ans1.end());
	
	sort(ans0.begin(), ans0.end(), greater<int>());
	
	for(int i = 0, j = 0, k = 0; i < ans1.size(); i++){
		ans.push_back(ans1[i]);
	}
	for(int i = 0, j = 0, k = 0; i < ans0.size(); i++){
		ans.push_back(ans0[i]);
	}
	
	for(int i = 0, now = 0; i < ans.size(); i++){
		print(ans[i],now);
		if(ans[i]%2==0) now = !now;
	}
	cout<<endl;
	
	return 0;
}
0