結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー okok
提出日時 2019-09-01 15:13:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,934 bytes
コンパイル時間 1,215 ms
コンパイル使用メモリ 96,832 KB
実行使用メモリ 10,860 KB
最終ジャッジ日時 2023-09-06 11:59:53
合計ジャッジ時間 4,519 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
9,888 KB
testcase_01 AC 64 ms
9,508 KB
testcase_02 AC 266 ms
10,568 KB
testcase_03 WA -
testcase_04 AC 3 ms
8,656 KB
testcase_05 AC 3 ms
8,720 KB
testcase_06 AC 3 ms
8,732 KB
testcase_07 AC 3 ms
8,644 KB
testcase_08 AC 58 ms
9,320 KB
testcase_09 AC 4 ms
8,540 KB
testcase_10 AC 4 ms
8,548 KB
testcase_11 AC 3 ms
8,548 KB
testcase_12 AC 16 ms
8,924 KB
testcase_13 AC 2 ms
8,588 KB
testcase_14 AC 3 ms
8,644 KB
testcase_15 AC 3 ms
8,720 KB
testcase_16 AC 3 ms
8,620 KB
testcase_17 AC 3 ms
8,544 KB
testcase_18 AC 4 ms
8,620 KB
testcase_19 WA -
testcase_20 AC 3 ms
8,544 KB
testcase_21 AC 3 ms
8,544 KB
testcase_22 AC 3 ms
8,648 KB
testcase_23 AC 3 ms
8,548 KB
testcase_24 AC 3 ms
8,548 KB
testcase_25 AC 2 ms
8,548 KB
testcase_26 WA -
testcase_27 AC 3 ms
8,788 KB
testcase_28 AC 3 ms
8,588 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 3 ms
8,612 KB
testcase_32 AC 9 ms
8,804 KB
testcase_33 AC 4 ms
8,584 KB
testcase_34 AC 36 ms
9,260 KB
testcase_35 AC 286 ms
10,688 KB
testcase_36 AC 147 ms
10,116 KB
testcase_37 WA -
testcase_38 AC 269 ms
10,688 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[i] + 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