結果

問題 No.1477 Lamps on Graph
ユーザー fgwiebfaoishfgwiebfaoish
提出日時 2021-04-16 22:05:15
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 364 ms / 2,000 ms
コード長 2,893 bytes
コンパイル時間 2,426 ms
コンパイル使用メモリ 109,632 KB
実行使用メモリ 48,880 KB
最終ジャッジ日時 2023-09-16 00:45:44
合計ジャッジ時間 13,062 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
20,780 KB
testcase_01 AC 64 ms
22,848 KB
testcase_02 AC 63 ms
20,860 KB
testcase_03 AC 65 ms
20,804 KB
testcase_04 AC 63 ms
20,896 KB
testcase_05 AC 65 ms
20,876 KB
testcase_06 AC 65 ms
20,872 KB
testcase_07 AC 63 ms
22,840 KB
testcase_08 AC 64 ms
20,936 KB
testcase_09 AC 62 ms
18,796 KB
testcase_10 AC 66 ms
18,812 KB
testcase_11 AC 64 ms
20,868 KB
testcase_12 AC 233 ms
40,076 KB
testcase_13 AC 216 ms
38,824 KB
testcase_14 AC 264 ms
37,312 KB
testcase_15 AC 160 ms
29,708 KB
testcase_16 AC 132 ms
32,672 KB
testcase_17 AC 126 ms
34,368 KB
testcase_18 AC 231 ms
43,256 KB
testcase_19 AC 208 ms
40,116 KB
testcase_20 AC 135 ms
28,744 KB
testcase_21 AC 205 ms
46,936 KB
testcase_22 AC 112 ms
28,368 KB
testcase_23 AC 190 ms
30,720 KB
testcase_24 AC 309 ms
46,036 KB
testcase_25 AC 147 ms
29,368 KB
testcase_26 AC 273 ms
42,544 KB
testcase_27 AC 176 ms
33,164 KB
testcase_28 AC 197 ms
38,148 KB
testcase_29 AC 187 ms
33,664 KB
testcase_30 AC 148 ms
40,624 KB
testcase_31 AC 135 ms
34,160 KB
testcase_32 AC 346 ms
48,108 KB
testcase_33 AC 337 ms
47,828 KB
testcase_34 AC 305 ms
48,528 KB
testcase_35 AC 364 ms
46,724 KB
testcase_36 AC 360 ms
46,696 KB
testcase_37 AC 334 ms
48,880 KB
testcase_38 AC 349 ms
46,844 KB
testcase_39 AC 363 ms
44,716 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 System.Threading;
using System.Runtime.CompilerServices;
static class Program{
	const int mod=(int)1e9+7;
	static List<int>[] li;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		int n=s[0],m=s[1];//n-1;
		li=new List<int>[n+1];
		var h=new (int,int)[n];
		var a=sc.Ia2;
		for(int i=1;i<=n;i++){
			h[i-1]=(i,a[i]);
			li[i]=new List<int>();
		}
		for(int i=0;i<m;i++){
			var e=sc.Ia;
			if(a[e[0]]<a[e[1]]){li[e[0]].Add(e[1]);}
			else if(a[e[0]]>a[e[1]]){li[e[1]].Add(e[0]);}
		}
		var q=sc.I;
		var c=sc.Ia;
		var g=new bool[n+1];
		for(int i = 0;i<q;i++) {g[c[i]]=true;}
		Array.Sort(h,(u,v)=>u.Item2-v.Item2);
		int ans=0;
		var lia=new List<int>();
		for(int i = 0;i<n;i++) {
			if(g[h[i].Item1]){
				ans++;
				lia.Add(h[i].Item1);
				for(int j = 0;j<li[h[i].Item1].Count;j++) {g[li[h[i].Item1][j]]^=true;}
			}
		}
		Console.WriteLine("{0}",ans);
		Console.WriteLine("{0}",string.Join("\n",lia));
	}
}

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