結果

問題 No.483 マッチ並べ
ユーザー kotamanegikotamanegi
提出日時 2017-02-10 22:35:08
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,695 bytes
コンパイル時間 913 ms
コンパイル使用メモリ 98,568 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-28 10:33:21
合計ジャッジ時間 2,490 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONG_INF 800000000000000000
vector<int> vertexs[200];
int color_vertexs[200] = {};
map<pair<int, int>,vector<int>> hogee;
int main() {
	int n;
	cin >> n;
	for (int j = 0;j < n;++j) {
		int a[2], b[2];
		REP(i, 2) {
			cin >> a[i] >> b[i];
		}
		for (int i = 0;i < 2;++i) {
			for (int q = 0;q < hogee[make_pair(a[i], b[i])].size();++q) {
				vertexs[j].push_back(hogee[make_pair(a[i], b[i])][q]);
				vertexs[hogee[make_pair(a[i], b[i])][q]].push_back(j);
			}
			hogee[make_pair(a[i], b[i])].push_back(j);
		}
	}
	for (int i = 0;i < n;++i) {
		color_vertexs[i] = 2;
	}
	for (int i = 0;i < n;++i) {
		if (color_vertexs[i] == 2) {
			color_vertexs[i] = 0;
			queue<int> wow;
			wow.push(i);
			while (wow.empty() == false) {
				int hoge = wow.front();
				wow.pop();
				for (int q = 0;q < vertexs[hoge].size();++q) {
					if (color_vertexs[vertexs[hoge][q]] != 2) {
						if ((color_vertexs[hoge] == color_vertexs[vertexs[hoge][q]])) {
							cout << "NO" << endl;
							return 0;
						}
					}
					else {
						color_vertexs[vertexs[hoge][q]] = (color_vertexs[hoge] + 1) % 2;
						wow.push(vertexs[hoge][q]);
					}
				}
			}
		}
	}
	cout << "YES" << endl;
	return 0;
}
0