結果
問題 | No.274 The Wall |
ユーザー |
![]() |
提出日時 | 2015-08-29 10:32:21 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,470 bytes |
コンパイル時間 | 828 ms |
コンパイル使用メモリ | 91,756 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-22 02:02:48 |
合計ジャッジ時間 | 1,458 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
ソースコード
#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;}