結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー okok
提出日時 2019-09-01 15:45:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,947 bytes
コンパイル時間 1,266 ms
コンパイル使用メモリ 96,896 KB
実行使用メモリ 10,708 KB
最終ジャッジ日時 2023-09-06 12:00:30
合計ジャッジ時間 5,307 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 169 ms
10,012 KB
testcase_01 AC 89 ms
9,416 KB
testcase_02 AC 359 ms
10,640 KB
testcase_03 AC 295 ms
10,708 KB
testcase_04 AC 3 ms
8,660 KB
testcase_05 AC 4 ms
8,624 KB
testcase_06 AC 3 ms
8,580 KB
testcase_07 AC 3 ms
8,648 KB
testcase_08 AC 72 ms
9,348 KB
testcase_09 AC 3 ms
8,564 KB
testcase_10 AC 4 ms
8,724 KB
testcase_11 AC 3 ms
8,648 KB
testcase_12 AC 21 ms
8,892 KB
testcase_13 AC 3 ms
8,640 KB
testcase_14 AC 3 ms
8,580 KB
testcase_15 AC 3 ms
8,552 KB
testcase_16 AC 3 ms
8,580 KB
testcase_17 AC 3 ms
8,720 KB
testcase_18 AC 3 ms
8,616 KB
testcase_19 WA -
testcase_20 AC 3 ms
8,564 KB
testcase_21 AC 4 ms
8,556 KB
testcase_22 AC 3 ms
8,608 KB
testcase_23 AC 4 ms
8,576 KB
testcase_24 AC 3 ms
8,636 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 3 ms
8,652 KB
testcase_28 AC 3 ms
8,720 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 4 ms
8,720 KB
testcase_32 AC 12 ms
8,904 KB
testcase_33 AC 5 ms
8,624 KB
testcase_34 AC 49 ms
9,280 KB
testcase_35 AC 380 ms
10,596 KB
testcase_36 AC 196 ms
10,052 KB
testcase_37 WA -
testcase_38 AC 364 ms
10,600 KB
権限があれば一括ダウンロードができます

ソースコード

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 = 310000;
int hoge[MAX];
int fuga[MAX];
int temp[MAX];

int print(int x, int y){
	
	for(int i = 0; i < x; i++, y = !y){
		cout<<y;
	}
	
	return !y;
}
signed main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	int N;
	deque<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] + i < hoge[j+i*i]){
					hoge[j+i*i] = hoge[j] + i;
					fuga[j+i*i] = j;
					temp[j+i*i] = i;
				} else if(hoge[j] + i == hoge[j+i*i]){
					if(i%2){
						if(temp[j+i*i]%2){
							if(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;; i = fuga[i]){
		if(i){
			if(temp[i]%2) ans1.push_back(temp[i]);
			else ans0.push_back(temp[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; ans.size(); i++){
		if(!now){
			now = print(ans.front(),now);
			ans.pop_front();
		} else {
			now = print(ans.back(),now);
			ans.pop_back();
		}
	}
	cout<<endl;
	
	return 0;
}
0