結果

問題 No.274 The Wall
ユーザー mayoko_mayoko_
提出日時 2015-08-29 10:25:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,470 bytes
コンパイル時間 702 ms
コンパイル使用メモリ 85,332 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 19:38:39
合計ジャッジ時間 1,742 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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-1;
        } 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;
}
0