結果

問題 No.274 The Wall
ユーザー 👑 rin204rin204
提出日時 2022-07-04 17:31:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,337 bytes
コンパイル時間 2,230 ms
コンパイル使用メモリ 208,836 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-21 01:15:41
合計ジャッジ時間 3,532 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/lazysegtree>
using namespace std;
using namespace atcoder;

using S = int;
using F = int;

S e(){
    return 0;
}

S op(S l, S r){
    return max(l, r);
}

S mapping(F l, S r){
    return l + r;
}

F composition(F l, F r){
    return l + r;
}

F id(){
    return 0;
}

void solve(){
    int n, m;
    cin >> n >> m;
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(m);
    vector<pair<int, int>> lr(n);
    int l, r, ll, rr;
    for(int i = 0; i < n; i++){
        cin >> l >> r;
        if(l > r) swap(l, r);
        ll = m - 1 - r;
        rr = m - 1 - l;
        if(r <= rr) lr[i] = {l, r};
        else lr[i] = {ll, rr};
    }
    sort(lr.begin(), lr.end(), [](auto l, auto r){return l.second < r.second;});
    for(auto tmp:lr){
        l = tmp.first;
        r = tmp.second;
        int ma = seg.prod(l, r + 1);
        if(ma == 0){
            seg.apply(l, r + 1, 1);
            continue;
        }
        ll = m - 1 - r;
        rr = m - 1 - l;
        ma = seg.prod(ll, rr + 1);
        if(ma == 0){
            seg.apply(ll, rr + 1, 1);
        }
        else{
            cout << "NO\n";
            return;
        }
    }
    cout << "YES\n";
}

int main(){
    cin.tie(0)->sync_with_stdio(0);
    int t;
    t = 1;
    //cin >> t;
    while(t--) solve();
}
    
    


0