結果

問題 No.274 The Wall
ユーザー face4face4
提出日時 2019-09-25 13:57:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 846 bytes
コンパイル時間 2,277 ms
コンパイル使用メモリ 78,848 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 03:19:16
合計ジャッジ時間 2,733 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<bool> w(m, 0);
    vector<pair<int,int>> vp;
    for(int i = 0; i < n; i++){
        int x, y;
        cin >> x >> y;
        vp.push_back({x, y});
    }
    sort(vp.begin(), vp.end());
    for(int i = 0; i < n; i++){
        int l = vp[i].first, r = vp[i].second;
        bool ok = true;
        for(int j = l; j <= r; j++) ok &= !w[j];
        if(ok){
            for(int j = l; j <= r; j++) w[j] = true;
            continue;
        }
        ok = true;
        for(int j = l; j <= r; j++) ok &= !w[m-1-j];
        if(ok){
            for(int j = l; j <= r; j++) w[m-1-j] = true;
            continue;
        }
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    return 0;
}
0