結果

問題 No.483 マッチ並べ
ユーザー kuuso1kuuso1
提出日時 2017-02-10 23:49:53
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,021 bytes
コンパイル時間 2,482 ms
コンパイル使用メモリ 108,988 KB
実行使用メモリ 22,900 KB
最終ジャッジ日時 2023-08-28 12:29:01
合計ジャッジ時間 8,049 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
20,640 KB
testcase_01 WA -
testcase_02 AC 66 ms
22,708 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 66 ms
20,576 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 63 ms
22,792 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 62 ms
20,616 KB
testcase_17 AC 64 ms
22,788 KB
testcase_18 AC 62 ms
20,864 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 65 ms
20,664 KB
testcase_23 AC 66 ms
20,580 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 65 ms
20,744 KB
testcase_28 AC 65 ms
20,740 KB
testcase_29 AC 64 ms
20,800 KB
testcase_30 WA -
testcase_31 AC 65 ms
20,756 KB
testcase_32 AC 68 ms
22,680 KB
testcase_33 AC 63 ms
20,676 KB
testcase_34 AC 66 ms
20,660 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 65 ms
22,704 KB
testcase_41 AC 64 ms
20,576 KB
testcase_42 AC 65 ms
20,756 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 64 ms
20,788 KB
testcase_54 WA -
testcase_55 AC 66 ms
20,648 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(){
		
		int H = 120;
		int W = 120;
		int HW = H*W;
		List<int>[] E = new List<int>[HW];
		for(int i=0;i<HW;i++) E[i] = new List<int>();
		
		Func<int,int,int> enc = (r,c) => r*W+c;
		
		var deg = new Dictionary<int,int>();
		for(int i=0;i<N;i++){
			int v = enc(R0[i],C0[i]);
			int w = enc(R1[i],C1[i]);
			E[v].Add(w);
			E[w].Add(v);
			if(!deg.ContainsKey(v))deg.Add(v,0);deg[v]++;
			if(!deg.ContainsKey(w))deg.Add(w,0);deg[w]++;
		}
		
		bool[] used = new bool[HW];
		foreach(var v in deg.Keys){
			if(used[v]) continue;
			int cnt = 0;
			Queue<int> Q = new Queue<int>();
			used[v] = true;
			Q.Enqueue(v);
			while(Q.Count>0){
				var now = Q.Dequeue();
				cnt += deg[now]%2;
				foreach(var nxt in E[now]){
					if(!used[nxt]){
						used[nxt] = true;
						Q.Enqueue(nxt);
					}
				}
			}
			if(cnt == 2 || cnt == 0) continue;
			Console.WriteLine("NO");
			return;
		}
		Console.WriteLine("YES");
		
		
	}
	int N;
	int[] R0,C0,R1,C1;
	public Sol(){
		N = ri();
		R0 = new int[N];
		R1 = new int[N];
		C0 = new int[N];
		C1 = new int[N];
		for(int i=0;i<N;i++){
			var d = ria();
			R0[i] = d[0];
			C0[i] = d[1];
			R1[i] = d[2];
			C1[i] = d[3];
			
		}
	}

	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