結果

問題 No.274 The Wall
ユーザー askr58askr58
提出日時 2023-09-21 01:15:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 386 ms / 2,000 ms
コード長 1,226 bytes
コンパイル時間 4,757 ms
コンパイル使用メモリ 267,564 KB
実行使用メモリ 192,888 KB
最終ジャッジ日時 2023-09-21 01:15:18
合計ジャッジ時間 7,475 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 119 ms
69,224 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 386 ms
192,888 KB
testcase_12 AC 31 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 10 ms
4,376 KB
testcase_15 AC 23 ms
4,380 KB
testcase_16 AC 138 ms
51,880 KB
testcase_17 AC 130 ms
50,408 KB
testcase_18 AC 151 ms
70,296 KB
testcase_19 AC 42 ms
4,376 KB
testcase_20 AC 48 ms
4,376 KB
testcase_21 AC 50 ms
4,376 KB
testcase_22 AC 53 ms
4,380 KB
testcase_23 AC 53 ms
4,380 KB
testcase_24 AC 53 ms
4,376 KB
testcase_25 AC 53 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
ll inf=1000000000000000;
using mint=modint998244353;
using pint=pair<mint,mint>;

bool is_prime(int l1,int l2,int r1,int r2){
    return !((l1<=r2&&r2<=r1)||(l2<=r1&&r1<=r2));
}
int main()
{
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> s(n);
    for(int i=0;i<n;i++)cin>>s[i].first>>s[i].second;
    scc_graph g(2*n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j)continue;
            int l1=s[i].first,l2=s[j].first,r1=s[i].second,r2=s[j].second;
            if(!is_prime(l1,l2,r1,r2))g.add_edge(i,j+n);
            if(!is_prime(l1,m-1-r2,r1,m-1-l2))g.add_edge(i,j);
            if(!is_prime(m-1-r1,l2,m-1-l1,r2))g.add_edge(i+n,j+n);
            if(!is_prime(m-1-r1,m-1-r2,m-1-l1,m-1-l2))g.add_edge(i+n,j);

        }
    }

    vector<vector<int>> scc=g.scc();
    bool ok=true;

    for(vector<int> v:scc){
        sort(v.begin(),v.end());
        for(int x:v){
            if(x>=n)break;
            if(lower_bound(v.begin(),v.end(),x+n)!=v.end()&&*lower_bound(v.begin(),v.end(),x+n)==x+n)ok=false;
        }
    }
    cout<<(ok?"YES":"NO")<<endl;

    

    


    
}
0