結果

問題 No.274 The Wall
ユーザー koyumeishikoyumeishi
提出日時 2015-08-28 22:57:45
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,218 bytes
コンパイル時間 974 ms
コンパイル使用メモリ 83,188 KB
実行使用メモリ 820,748 KB
最終ジャッジ日時 2023-09-25 19:26:00
合計ジャッジ時間 5,142 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 MLE -
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>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
using namespace std;

bool comp(const pair<int,int>& x, const pair<int,int>& y){
	if(x.first != y.first) return x.second < y.second;
	else return x.first < y.first;
}

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> L(n),R(n);
	for(int i=0; i<n; i++){
		cin >> L[i] >> R[i];
	}

	vector<pair<int,int>> v(n);
	for(int i=0; i<n; i++){
		if(L[i] >= m/2){
			swap(L[i], R[i]);
			L[i] = m-1 - L[i];
			R[i] = m-1 - R[i];
		}
		v[i] = {L[i], R[i]};
	}

	sort(v.begin(), v.end(), comp);
	vector<pair<int,int>> next;
	next.push_back({-1,m});
	for(int i=0; i<n; i++){
		vector<pair<int,int>> next_;
		for(int j=0; j<next.size(); j++){
			int l = v[i].first;
			int r = v[i].second;

			if(next[j].first < l && r < next[j].second){
				next_.push_back({r, next[j].second});
			}

			swap(l,r);
			l = m-1 - l;
			r = m-1 - r;

			if(next[j].first < l && r < next[j].second){
				next_.push_back({next[j].first, l});
			}
		}
		swap(next, next_);
	}

	if(next.size() == 0){
		cout << "NO" << endl;
	}else{
		cout << "YES" << endl;
	}

	return 0;
}
0