結果
| 問題 |
No.483 マッチ並べ
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2017-02-10 23:49:53 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,021 bytes |
| コンパイル時間 | 1,093 ms |
| コンパイル使用メモリ | 114,112 KB |
| 実行使用メモリ | 28,740 KB |
| 最終ジャッジ日時 | 2024-12-29 11:22:38 |
| 合計ジャッジ時間 | 4,413 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 19 WA * 34 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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));}
}
kuuso1