結果

問題 No.274 The Wall
ユーザー yudedakoyudedako
提出日時 2015-10-31 09:49:25
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,552 bytes
コンパイル時間 443 ms
コンパイル使用メモリ 61,132 KB
実行使用メモリ 8,708 KB
最終ジャッジ日時 2023-10-11 07:05:57
合計ジャッジ時間 4,075 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

class Line {
public:
	Line(const int &l = 0, const int &r = 0, const int &i = 0) :left(l), right(r), id(i) {}
	bool operator<(const Line &other) const {
		return left < other.left;
	}
	bool operator&(const Line &other) const {
		return ((left - other.right) * (right - other.left) < 0) && id != other.id;
	}
	void inspect() {
		std::cout << left << "-" << right << "\n";
	}
	int left, right, id;
};
template<typename T>
void sort(std::vector<T> &vector, const int &left, const int &right) {
	if (left < right) {
		auto l = left, r = right, pivot = (left + right) / 2;
		while (l < r) {
			while (vector.at(l) < vector.at(pivot)) ++l;
			while (vector.at(pivot) < vector.at(r)) --r;
			if (l < r) {
				auto temp = vector.at(l);
				vector.at(l) = vector.at(r); vector.at(r) = temp;
				++l; --r;
			}
			sort(vector, left, r); sort(vector, r + 1, right);
		}
	}
}
int main() {
	int n, m;
	std::cin >> n >> m;
	std::vector<Line> vector(2 * n);
	for (auto i = 0; i < n; ++i) {
		int l, r;
		std::cin >> l >> r;
		vector.at(2 * i) = Line(l, r, i);
		vector.at(2 * i + 1) = Line(m - r - 1, m - l - 1, i);
	}
	sort(vector, 0, (2 * n) - 1);
	bool flag = false;
	for (auto i = 2; i < 2 * n; ++i) {
		if (vector.at(i - 1) & vector.at(i) && vector.at(i - 2) & vector.at(i - 1) && vector.at(i - 2) & vector.at(i)) {
			//vector.at(i - 2).inspect(); vector.at(i - 1).inspect(); vector.at(i).inspect();
			flag = true;
			i = 2 * n;
		}
	}
	if (flag) {
		std::cout << "NO\n";
	}
	else{
		std::cout << "YES\n";
	}
	return 0;
}
0