結果

問題 No.483 マッチ並べ
ユーザー kotamanegikotamanegi
提出日時 2017-02-10 23:21:36
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 2,063 bytes
コンパイル時間 899 ms
コンパイル使用メモリ 100,040 KB
実行使用メモリ 7,616 KB
最終ジャッジ日時 2023-08-28 12:23:03
合計ジャッジ時間 4,366 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 can_be_ignored[200] = {};
map<pair<int, int>, vector<int>> hogee;
int already_visited[200] = {};
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);
		}
	}
	int cnt = 1;
	while (cnt != 0) {
		cnt = 0;
		for (int i = 0;i < n;++i) {
			if (can_be_ignored[i] == false) {
				int woww = 0;
				for (int q = 0;q < vertexs[i].size();++q) {
					if (can_be_ignored[vertexs[i][q]] == false) woww++;
				}
				if (woww <= 1) {
					can_be_ignored[i] = true;
					cnt++;
				}
			}
		}
	}
	for (int t = 0;t < n;++t) {
		if (already_visited[t] == false&&can_be_ignored[t] == false) {
			already_visited[t] = true;
			queue<int> ja;
			ja.push(t);
			while (ja.empty() == false) {
				int hogehoge = ja.front();
				int cnt = 0;
				for (int i = 0;i < vertexs[hogehoge].size();++i) {
					if (can_be_ignored[vertexs[hogehoge][i]] == false && already_visited[vertexs[hogehoge][i]] == 0) {
						cnt++;
						already_visited[vertexs[hogehoge][i]] = true;
						ja.push(vertexs[hogehoge][i]);
					}
				}
				if (cnt >= 2) {
					if (hogehoge != t|| cnt >= 3) {
						cout << "NO" << endl;
						return 0;
					}
				}
			}
		}
	}
	cout << "YES" << endl;
	return 0;
}
0