結果

問題 No.274 The Wall
ユーザー blackyukiblackyuki
提出日時 2021-02-06 15:04:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,854 bytes
コンパイル時間 2,196 ms
コンパイル使用メモリ 211,628 KB
実行使用メモリ 302,932 KB
最終ジャッジ日時 2023-09-15 22:15:23
合計ジャッジ時間 5,034 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 217 ms
124,404 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 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 655 ms
302,932 KB
testcase_12 AC 9 ms
4,380 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 140 ms
70,064 KB
testcase_17 AC 134 ms
67,100 KB
testcase_18 AC 142 ms
72,700 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 19 ms
4,380 KB
testcase_23 AC 19 ms
4,380 KB
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define rsort(a) {sort(all(a));reverse(all(a));}
#define pb emplace_back
#define lb(v,k) (lower_bound(all(v),(k))-v.begin())
#define fi first
#define se second
#define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
#define dame(a) {cout<<a<<endl;return 0;}
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vvvp=vector<vvp>;
using vb=vector<bool>;
using vvb=vector<vb>;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
const ll inf=1001001001001001001;
vi scc(vvi&g,ll&number_of_components){
    ll n=g.size();
    number_of_components=0;
    vvi rg(n);rep(i,n)for(ll x:g[i])rg[x].pb(i);
    vi topo,res(n);
    vb visited(n,false);
    function<void(ll,ll)> dfs=[&](ll i,ll md){
        visited[i]=true;
        if(md==0){
            for(ll x:g[i])if(!visited[x])dfs(x,md);
            topo.pb(i);
        }
        else{
            for(ll x:rg[i])if(!visited[x])dfs(x,md);
            res[i]=number_of_components;
        }
    };
    rep(i,n)if(!visited[i])dfs(i,0);
    reverse(all(topo));
    rep(i,n)visited[i]=false;
    for(ll i:topo)if(!visited[i]){
        dfs(i,1);
        number_of_components++;
    }
    return res;
}
int main(){
    ll n,m;cin>>n>>m;
    vp v(n);rep(i,n)cin>>v[i].fi>>v[i].se;
    vvi g(n*2);
    auto rev=[&](P p){
        return P(m-1-p.se,m-1-p.fi);
    };
    auto no=[&](P a,P b){
        if(a.se<b.fi)return false;
        if(b.se<a.fi)return false;
        return true;
    };
    rep(i,n)rep(j,i){
        if(no(v[i],v[j])){
            g[i].pb(j+n);
            g[j].pb(i+n);
        }
        if(no(rev(v[i]),v[j])){
            g[i+n].pb(j+n);
            g[j].pb(i);
        }
        if(no(v[i],rev(v[j]))){
            g[i].pb(j);
            g[j+n].pb(i);
        }
        if(no(rev(v[i]),rev(v[j]))){
            g[i+n].pb(j);
            g[j+n].pb(i);
        }
    }
    ll c;vi res=scc(g,c);
    rep(i,n)if(res[i]==res[i+n])dame("NO");
    out("YES");
}
0