結果

問題 No.479 頂点は要らない
ユーザー kuuso1kuuso1
提出日時 2017-01-27 23:13:34
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 226 ms / 1,500 ms
コード長 1,694 bytes
コンパイル時間 2,454 ms
コンパイル使用メモリ 107,948 KB
実行使用メモリ 36,892 KB
最終ジャッジ日時 2023-08-25 10:29:54
合計ジャッジ時間 8,932 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
22,940 KB
testcase_01 AC 65 ms
22,812 KB
testcase_02 AC 65 ms
22,780 KB
testcase_03 AC 64 ms
22,812 KB
testcase_04 AC 64 ms
22,896 KB
testcase_05 AC 66 ms
22,916 KB
testcase_06 AC 63 ms
22,844 KB
testcase_07 AC 65 ms
22,904 KB
testcase_08 AC 64 ms
24,896 KB
testcase_09 AC 64 ms
22,764 KB
testcase_10 AC 64 ms
22,828 KB
testcase_11 AC 64 ms
22,888 KB
testcase_12 AC 65 ms
24,996 KB
testcase_13 AC 65 ms
22,832 KB
testcase_14 AC 66 ms
24,772 KB
testcase_15 AC 65 ms
24,764 KB
testcase_16 AC 64 ms
22,936 KB
testcase_17 AC 65 ms
24,900 KB
testcase_18 AC 66 ms
24,808 KB
testcase_19 AC 68 ms
24,884 KB
testcase_20 AC 69 ms
22,832 KB
testcase_21 AC 69 ms
24,768 KB
testcase_22 AC 67 ms
22,684 KB
testcase_23 AC 68 ms
22,908 KB
testcase_24 AC 67 ms
22,776 KB
testcase_25 AC 67 ms
22,776 KB
testcase_26 AC 226 ms
35,008 KB
testcase_27 AC 221 ms
35,096 KB
testcase_28 AC 193 ms
36,892 KB
testcase_29 AC 202 ms
35,892 KB
testcase_30 AC 198 ms
33,820 KB
testcase_31 AC 199 ms
33,788 KB
testcase_32 AC 199 ms
33,712 KB
testcase_33 AC 190 ms
30,412 KB
testcase_34 AC 209 ms
34,212 KB
testcase_35 AC 199 ms
30,508 KB
testcase_36 AC 151 ms
29,904 KB
testcase_37 AC 204 ms
35,468 KB
testcase_38 AC 184 ms
34,708 KB
testcase_39 AC 150 ms
33,712 KB
testcase_40 AC 157 ms
27,428 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;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		Pair[] P = new Pair[M];
		for(int i=0;i<M;i++){
			P[i] = new Pair(A[i],B[i]);
		}
		Array.Sort(P,(p,q) => p.B.CompareTo(q.B) == 0 ? p.A.CompareTo(q.A) : p.B.CompareTo(q.B));
		Array.Reverse(P);
		
		var H = new HashSet<int>();
		for(int i=0;i<M;i++){
			if(H.Contains(P[i].A) || H.Contains(P[i].B)) continue;
			 H.Add(P[i].A);
		}
		
		var LL = new LinkedList<char>();
		for(int i=0;i<N;i++){
			LL.AddFirst(H.Contains(i) ? '1' : '0');
		}
		while(LL.First.Value == '0') LL.RemoveFirst();
		Console.WriteLine(new String(LL.ToArray()));
		
		
	}
	
	class Pair{
		public int A,B;
		public Pair(int a, int b){
			A = a; B = b;
		}
	}
	
	int N,M;
	int[] A,B;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		A = new int[M];
		B = new int[M];
		for(int i=0;i<M;i++){
			d = ria();
			Array.Sort(d);
			A[i] = d[0]; B[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}
0