結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー fgwiebfaoishfgwiebfaoish
提出日時 2020-06-12 13:33:22
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 3,452 bytes
コンパイル時間 4,524 ms
コンパイル使用メモリ 109,420 KB
実行使用メモリ 63,672 KB
最終ジャッジ日時 2023-09-06 09:09:20
合計ジャッジ時間 12,689 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 374 ms
50,908 KB
testcase_01 WA -
testcase_02 AC 682 ms
63,672 KB
testcase_03 AC 586 ms
55,164 KB
testcase_04 WA -
testcase_05 AC 83 ms
22,752 KB
testcase_06 AC 83 ms
24,652 KB
testcase_07 AC 82 ms
22,672 KB
testcase_08 AC 213 ms
35,396 KB
testcase_09 AC 82 ms
24,688 KB
testcase_10 AC 83 ms
22,664 KB
testcase_11 AC 82 ms
22,708 KB
testcase_12 AC 123 ms
30,740 KB
testcase_13 AC 83 ms
20,588 KB
testcase_14 AC 82 ms
20,604 KB
testcase_15 AC 83 ms
22,652 KB
testcase_16 AC 82 ms
22,544 KB
testcase_17 AC 83 ms
24,588 KB
testcase_18 AC 82 ms
22,652 KB
testcase_19 AC 84 ms
24,892 KB
testcase_20 AC 83 ms
22,712 KB
testcase_21 AC 83 ms
24,708 KB
testcase_22 AC 83 ms
22,584 KB
testcase_23 AC 83 ms
22,528 KB
testcase_24 AC 83 ms
22,500 KB
testcase_25 AC 82 ms
22,732 KB
testcase_26 AC 82 ms
22,624 KB
testcase_27 AC 82 ms
22,656 KB
testcase_28 AC 81 ms
20,700 KB
testcase_29 AC 83 ms
22,536 KB
testcase_30 AC 83 ms
22,648 KB
testcase_31 AC 83 ms
24,592 KB
testcase_32 AC 100 ms
25,056 KB
testcase_33 AC 86 ms
22,772 KB
testcase_34 AC 169 ms
33,940 KB
testcase_35 AC 710 ms
62,616 KB
testcase_36 AC 420 ms
49,980 KB
testcase_37 AC 788 ms
60,732 KB
testcase_38 AC 706 ms
61,436 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
//using nint=System.Int32;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var dp1=new int[n+1];
		var dp2=new int[n+1];
		var dp3=new int[n+1];
		var dp4=new int[n+1];
		var li=new List<int>[n+1];
		for(int i = 1;i<=n;i++) {
			dp1[i]=int.MaxValue;
			for(int j = 1;j*j<=i;j++) {
				if(dp1[i]>dp1[i-j*j]+j){
					dp1[i]=dp1[i-j*j]+j;
					dp4[i]=dp4[i-j*j]+1;
					dp2[i]=i-j*j;
					dp3[i]=Fu(dp3[i-j*j],j);
					li[i]=new List<int>();
					li[i].Add(i-j*j);
				}
				else if(dp1[i]==dp1[i-j*j]+j){
					dp4[i]=dp4[i-j*j]+1;
					dp2[i]=i-j*j;
					dp3[i]=Fu(dp3[i-j*j],j);
					li[i].Add(i-j*j);
				}
			}
		}
		var d=new int[50];
		StringBuilder ans=new StringBuilder("1");
		Fu2(n,0);
		void Fu2(int p,int g){
			if(p==0){
				var h=d.Skip(0).Take(g).ToArray(); 
				Array.Sort(h,(u,v)=>v==Fu(v,u)?1:-1);
				var sb=new StringBuilder();
				for(int i = 0,k=1;i<h.Length;i++) {
					var c=new int[h[i]];
					for(int j = k;j<h[i];j+=2) {c[j]=1;}
					sb.Append(String.Join("",c).ToArray());
					k=c[c.Length-1]^1;
				}
				if(ans.ToString().CompareTo(sb.ToString())==1){ans=sb;}
				return;
			}
			for(int i = 0;i<li[p].Count;i++) {
				d[g]=(int)Sqrt(p-li[p][i]);
				Fu2(li[p][i],g+1);
			}
		}
		Console.WriteLine(ans);
		int Fu(int a,int b) {
			if((a&1)==1&&(b&1)==0){return a;}
			if((a&1)==0&&(b&1)==1){return b;}
			if((a&1)==0&&(b&1)==0){return Max(a,b);}
			return Min(a,b);
		}
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}
0