結果

問題 No.483 マッチ並べ
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2017-02-11 00:23:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,003 bytes
コンパイル時間 1,995 ms
コンパイル使用メモリ 172,196 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-28 12:32:10
合計ジャッジ時間 3,935 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 WA -
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 3 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 3 ms
4,380 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 2 ms
4,376 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 2 ms
4,376 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 2 ms
4,376 KB
testcase_51 AC 3 ms
4,380 KB
testcase_52 AC 2 ms
4,380 KB
testcase_53 AC 2 ms
4,376 KB
testcase_54 WA -
testcase_55 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)




int N;
set<int> vec;
vector<int> E[20101];
//-----------------------------------------------------------------
bool done[20101];
bool red[20101];
bool ans = true;
void dfs(int cur, int par) {
	done[cur] = true;
	for (int to : E[cur]) if (to != par && !done[to]) {
		if (!red[cur]) {
			red[cur] = true;
		}
		else {
			if (red[to]) {
				ans = false;
				return;
			}

			red[to] = true;
		}
	}

	for (int to : E[cur]) if (to != par && !done[to]) dfs(to, cur);
}
//-----------------------------------------------------------------
int main() {
	cin >> N;
	rep(i, 0, N) {
		int r0, c0, r1, c1;
		scanf("%d %d %d %d", &r0, &c0, &r1, &c1);
		r0--; c0--; r1--; c1--;

		int a = r0 * 150 + c0;
		int b = r1 * 150 + c1;
		vec.insert(a);
		vec.insert(b);
		E[a].push_back(b);
		E[b].push_back(a);
	}

	for (int i : vec) if (!done[i] && E[i].size() == 1) dfs(i, -1);

	if (ans)
		printf("YES\n");
	else
		printf("NO\n");
}
0