提出 #67352143


ソースコード 拡げる

#include<bits/stdc++.h>
#define ll long long
using namespace std;

const int Maxn=1e6+6;
int h,w,k;

struct seg{
    int l,r;
    mutable int id;
    seg(int l=0,int r=0,int id=0):l(l),r(r),id(id){}
    inline friend bool operator <(const seg x,const seg y){
        return x.l<y.l;
    }
};
set<seg>s[Maxn];
int cnt;

vector<int>e[Maxn];
bool vis[Maxn];

void dfs(int u){
    vis[u]=1;
    for(auto v:e[u]){
        if(vis[v]) continue;
        dfs(v);
    }
}

int main(){
    cin>>h>>w>>k;

    for(int i=1;i<=h;i++){
        s[i].insert(seg(1,w,0));
    }
    for(int i=1;i<=k;i++){
        int r,c;
        cin>>r>>c;
        auto it=s[r].upper_bound(seg(c,0,0)); it--;
        int l=(it->l),rr=(it->r); 
        s[r].erase(it);
        if(c>l) s[r].insert(seg(l,c-1,0));
        if(rr>c) s[r].insert(seg(c+1,rr,0));
    }
    for(int i=1;i<=h;i++){
        for(auto &j:s[i]){
            j.id=++cnt;
        }
    }
    for(int i=1;i<h;i++){
        for(auto j:s[i]){
            int l=j.l,r=j.r;
            auto itr=s[i+1].upper_bound(seg(r,0,0)),itl=s[i+1].upper_bound(seg(l,0,0));
            if(itl!=s[i+1].begin()) itl--;
            
            for(auto k=itl;k!=itr;k++){
                if(j.l>k->r or k->l>j.r) continue;
                e[j.id].emplace_back(k->id),e[k->id].emplace_back(j.id);
            } 
        }
    }
    dfs(1);

    if(vis[cnt]) puts("Yes");
    else puts("No");


    return 0;
}

提出情報

提出日時
問題 G - Big Banned Grid
ユーザ AceTaffy_
言語 C++ 20 (gcc 12.2)
得点 575
コード長 1493 Byte
結果 AC
実行時間 264 ms
メモリ 103284 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 575 / 575
結果
AC × 4
AC × 45
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 01_random_37.txt, 01_random_38.txt, 01_random_39.txt, 01_random_40.txt, 01_random_41.txt, 01_random_42.txt, 01_random_43.txt, 01_random_44.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 26 ms 50408 KiB
00_sample_01.txt AC 26 ms 50376 KiB
00_sample_02.txt AC 26 ms 50412 KiB
00_sample_03.txt AC 27 ms 50344 KiB
01_random_04.txt AC 258 ms 103284 KiB
01_random_05.txt AC 261 ms 103268 KiB
01_random_06.txt AC 261 ms 103272 KiB
01_random_07.txt AC 264 ms 103188 KiB
01_random_08.txt AC 263 ms 103272 KiB
01_random_09.txt AC 264 ms 103176 KiB
01_random_10.txt AC 117 ms 75848 KiB
01_random_11.txt AC 53 ms 57248 KiB
01_random_12.txt AC 254 ms 83028 KiB
01_random_13.txt AC 128 ms 75816 KiB
01_random_14.txt AC 181 ms 80580 KiB
01_random_15.txt AC 197 ms 83088 KiB
01_random_16.txt AC 57 ms 53888 KiB
01_random_17.txt AC 60 ms 59404 KiB
01_random_18.txt AC 90 ms 55200 KiB
01_random_19.txt AC 77 ms 53924 KiB
01_random_20.txt AC 34 ms 51568 KiB
01_random_21.txt AC 41 ms 53136 KiB
01_random_22.txt AC 237 ms 97912 KiB
01_random_23.txt AC 225 ms 96604 KiB
01_random_24.txt AC 240 ms 98080 KiB
01_random_25.txt AC 236 ms 97088 KiB
01_random_26.txt AC 236 ms 96668 KiB
01_random_27.txt AC 241 ms 97120 KiB
01_random_28.txt AC 103 ms 64088 KiB
01_random_29.txt AC 141 ms 78252 KiB
01_random_30.txt AC 116 ms 71364 KiB
01_random_31.txt AC 184 ms 69064 KiB
01_random_32.txt AC 60 ms 77584 KiB
01_random_33.txt AC 175 ms 79432 KiB
01_random_34.txt AC 40 ms 53524 KiB
01_random_35.txt AC 60 ms 52252 KiB
01_random_36.txt AC 51 ms 52392 KiB
01_random_37.txt AC 78 ms 55020 KiB
01_random_38.txt AC 79 ms 57604 KiB
01_random_39.txt AC 26 ms 50488 KiB
01_random_40.txt AC 26 ms 50480 KiB
01_random_41.txt AC 26 ms 50356 KiB
01_random_42.txt AC 31 ms 55360 KiB
01_random_43.txt AC 46 ms 68384 KiB
01_random_44.txt AC 48 ms 71896 KiB