結果
| 問題 |
No.274 The Wall
|
| コンテスト | |
| ユーザー |
mayoko_
|
| 提出日時 | 2015-08-29 10:32:21 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,470 bytes |
| コンパイル時間 | 931 ms |
| コンパイル使用メモリ | 94,480 KB |
| 実行使用メモリ | 7,324 KB |
| 最終ジャッジ日時 | 2025-03-17 18:46:58 |
| 合計ジャッジ時間 | 1,778 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 23 |
ソースコード
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
const int MAXN = 2020;
const int MAXM = 4020;
int L[MAXN], R[MAXN];
int N, M;
bool solve(const vector<pii>& walls) {
int l = 0, r = M-1;
for (auto p : walls) {
if (p.first >= l) {
if (p.second > r) {
return false;
}
l = p.second+1;
} else if (M-p.first-1 <= r) {
if (M-p.second-1 < l) {
return false;
}
r = M-p.second-2;
} else return false;
}
return true;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N >> M;
vector<pii> walls;
for (int i = 0; i < N; i++) {
cin >> L[i] >> R[i];
if (L[i] <= M-R[i]-1) walls.emplace_back(L[i], R[i]);
else walls.emplace_back(M-R[i]-1, M-L[i]-1);
}
sort(walls.begin(), walls.end());
cout << (solve(walls) ? "YES" : "NO") << endl;
return 0;
}
mayoko_