結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー kotatsugamekotatsugame
提出日時 2019-09-01 05:51:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 864 bytes
コンパイル時間 736 ms
コンパイル使用メモリ 77,512 KB
実行使用メモリ 4,648 KB
最終ジャッジ日時 2023-09-06 11:58:36
合計ジャッジ時間 3,371 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 33 ms
4,380 KB
testcase_02 AC 160 ms
4,548 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 28 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 8 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 5 ms
4,380 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 17 ms
4,376 KB
testcase_35 AC 155 ms
4,648 KB
testcase_36 AC 76 ms
4,376 KB
testcase_37 AC 154 ms
4,576 KB
testcase_38 AC 160 ms
4,536 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N;
vector<int>A[2];
int dp[3<<17];
main()
{
	cin>>N;
	dp[0]=0;
	for(int i=1;i<=N;i++)dp[i]=1e9;
	for(int i=0;i<N;i++)
	{
		for(int j=1;i+j*j<=N;j++)
		{
			dp[i+j*j]=min(dp[i+j*j],dp[i]+j);
		}
	}
	for(int i=1000;i;i--)
	{
		while(i*i<=N&&dp[N-i*i]+i==dp[N])
		{
			N-=i*i;
			A[i%2].push_back(i);
		}
	}
	string ans="0";
	for(int i=0;i<2;i++)sort(A[i].begin(),A[i].end());
	for(int v:A[1])
	{
		ans+=ans[ans.size()-1];
		for(int i=2;i<=v;i++)ans+=ans[ans.size()-1]=='0'?'1':'0';
	}
	int L=0,R=(int)A[0].size()-1;
	while(L<=R)
	{
		ans+=ans[ans.size()-1];
		for(int i=2;i<=A[0][R];i++)ans+=ans[ans.size()-1]=='0'?'1':'0';
		R--;
		if(L<=R)
		{
			ans+=ans[ans.size()-1];
			for(int i=2;i<=A[0][L];i++)ans+=ans[ans.size()-1]=='0'?'1':'0';
			L++;
		}
	}
	cout<<ans.substr(1)<<endl;
}
0