結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー kotatsugamekotatsugame
提出日時 2019-09-01 05:59:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 268 ms / 2,000 ms
コード長 853 bytes
コンパイル時間 582 ms
コンパイル使用メモリ 72,024 KB
実行使用メモリ 7,448 KB
最終ジャッジ日時 2023-09-02 07:11:37
合計ジャッジ時間 3,914 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
6,556 KB
testcase_01 AC 62 ms
6,324 KB
testcase_02 AC 255 ms
7,352 KB
testcase_03 AC 212 ms
7,092 KB
testcase_04 AC 2 ms
5,432 KB
testcase_05 AC 2 ms
5,456 KB
testcase_06 AC 2 ms
5,404 KB
testcase_07 AC 2 ms
5,532 KB
testcase_08 AC 56 ms
6,172 KB
testcase_09 AC 2 ms
5,604 KB
testcase_10 AC 2 ms
5,404 KB
testcase_11 AC 2 ms
5,412 KB
testcase_12 AC 16 ms
5,776 KB
testcase_13 AC 2 ms
5,404 KB
testcase_14 AC 2 ms
5,472 KB
testcase_15 AC 2 ms
5,412 KB
testcase_16 AC 2 ms
5,388 KB
testcase_17 AC 3 ms
5,388 KB
testcase_18 AC 2 ms
5,516 KB
testcase_19 AC 2 ms
5,408 KB
testcase_20 AC 2 ms
5,472 KB
testcase_21 AC 2 ms
5,604 KB
testcase_22 AC 2 ms
5,388 KB
testcase_23 AC 2 ms
5,616 KB
testcase_24 AC 2 ms
5,448 KB
testcase_25 AC 2 ms
5,416 KB
testcase_26 AC 2 ms
5,384 KB
testcase_27 AC 2 ms
5,384 KB
testcase_28 AC 2 ms
5,392 KB
testcase_29 AC 2 ms
5,384 KB
testcase_30 AC 2 ms
5,464 KB
testcase_31 AC 2 ms
5,404 KB
testcase_32 AC 9 ms
5,572 KB
testcase_33 AC 3 ms
5,440 KB
testcase_34 AC 35 ms
5,948 KB
testcase_35 AC 267 ms
7,280 KB
testcase_36 AC 140 ms
6,704 KB
testcase_37 AC 268 ms
7,448 KB
testcase_38 AC 268 ms
7,236 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:9:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    9 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N;
vector<int>A[2];
int dp[3<<17];
int L[3<<17],R[3<<17];
main()
{
	cin>>N;
	dp[0]=0;
	for(int i=1;i<=N;i++)
	{
		dp[i]=1e9;
		L[i]=-1;
		R[i]=-1;
	}
	for(int i=0;i<N;i++)
	{
		for(int j=1;i+j*j<=N;j++)
		{
			if(dp[i+j*j]>dp[i]+j)
			{
				dp[i+j*j]=dp[i]+j;
				L[i+j*j]=R[i+j*j]=j;
			}
			else if(dp[i+j*j]==dp[i]+j)
			{
				int u=i+j*j;
				if(L[u]%2!=j%2)
				{
					if(j%2)L[u]=j;
				}
				else
				{
					if(j%2)L[u]=min(L[u],j);
					else L[u]=max(L[u],j);
				}
				if(R[u]%2!=j%2)
				{
					if(j%2==0)R[u]=j;
				}
				else
				{
					if(j%2)R[u]=max(R[u],j);
					else R[u]=min(R[u],j);
				}
			}
		}
	}
	char c='0';
	while(N)
	{
		int id;
		if(c=='0')id=L[N];
		else id=R[N];
		N-=id*id;
		cout<<c;
		for(int i=2;i<=id;i++)cout<<(c^=1);
	}
	cout<<endl;
}
0