結果

問題 No.483 マッチ並べ
ユーザー fine
提出日時 2017-02-10 23:23:25
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 935 bytes
コンパイル時間 2,136 ms
コンパイル使用メモリ 187,228 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-29 11:13:57
合計ジャッジ時間 3,598 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> P;

struct Node {
	P p;
	int id;
	bool operator<(const Node& n) const {
		return id < n.id;
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	map<P, vector<int> > m;
	for (int i = 0; i < n; i++) {
		int r0, r1, c0, c1;
		cin >> r0 >> c0 >> r1 >> c1;
		P p1(r0, c0), p2(r1, c1);
		m[p1].push_back(i);
		m[p2].push_back(i);
	}

	vector<Node> a[5];
	for (auto p : m) {
		for (int i : p.second) {
			a[p.second.size()].push_back((Node){p.first, i});
		}
	}

	bool ans_flag = true;
	set<P> t;
	vector<bool> used(n, false);
	for (int i = 1; i <= 4; i++) {
		for (Node node : a[i]) {
			if (used[node.id]) continue;
			if (t.find(node.p) != t.end()) {
				ans_flag = false;
				break;
			} else {
				t.insert(node.p);
				used[node.id] = true;
			}
		}
		if (!ans_flag) break;
	}

	cout << (ans_flag ? "YES" : "NO") << endl;
	return 0;
}
0