結果

問題 No.2160 みたりのDominator
ユーザー hotman78hotman78
提出日時 2022-12-04 20:01:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,805 bytes
コンパイル時間 3,261 ms
コンパイル使用メモリ 222,568 KB
実行使用メモリ 77,344 KB
最終ジャッジ日時 2024-04-22 01:19:05
合計ジャッジ時間 15,613 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 1 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 WA -
testcase_38 AC 1 ms
5,376 KB
testcase_39 WA -
testcase_40 AC 75 ms
19,520 KB
testcase_41 AC 56 ms
15,396 KB
testcase_42 AC 39 ms
11,704 KB
testcase_43 AC 63 ms
16,548 KB
testcase_44 AC 73 ms
19,620 KB
testcase_45 AC 72 ms
17,476 KB
testcase_46 AC 53 ms
13,224 KB
testcase_47 AC 36 ms
9,916 KB
testcase_48 AC 57 ms
14,116 KB
testcase_49 AC 67 ms
16,424 KB
testcase_50 AC 61 ms
14,956 KB
testcase_51 AC 39 ms
12,584 KB
testcase_52 AC 56 ms
15,552 KB
testcase_53 AC 75 ms
19,744 KB
testcase_54 AC 43 ms
12,848 KB
testcase_55 AC 472 ms
46,472 KB
testcase_56 AC 380 ms
29,072 KB
testcase_57 AC 400 ms
33,460 KB
testcase_58 AC 413 ms
38,968 KB
testcase_59 AC 393 ms
33,904 KB
testcase_60 AC 328 ms
23,984 KB
testcase_61 AC 437 ms
44,668 KB
testcase_62 AC 461 ms
51,200 KB
testcase_63 AC 441 ms
46,632 KB
testcase_64 AC 312 ms
25,608 KB
testcase_65 AC 185 ms
40,712 KB
testcase_66 AC 239 ms
44,164 KB
testcase_67 AC 245 ms
45,816 KB
testcase_68 AC 508 ms
76,604 KB
testcase_69 AC 352 ms
57,636 KB
testcase_70 AC 495 ms
77,344 KB
testcase_71 AC 128 ms
31,860 KB
testcase_72 AC 290 ms
58,904 KB
testcase_73 AC 517 ms
70,416 KB
testcase_74 AC 491 ms
66,880 KB
testcase_75 AC 1 ms
5,376 KB
testcase_76 AC 2 ms
5,376 KB
testcase_77 AC 194 ms
45,144 KB
testcase_78 AC 265 ms
55,776 KB
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 WA -
testcase_83 AC 54 ms
14,816 KB
61_evil_bias_nocross_01.txt AC 74 ms
18,368 KB
61_evil_bias_nocross_02.txt AC 56 ms
14,504 KB
61_evil_bias_nocross_03.txt WA -
61_evil_bias_nocross_04.txt WA -
61_evil_bias_nocross_05.txt WA -
61_evil_bias_nocross_06.txt AC 66 ms
19,560 KB
61_evil_bias_nocross_07.txt AC 40 ms
11,816 KB
61_evil_bias_nocross_08.txt AC 55 ms
14,784 KB
61_evil_bias_nocross_09.txt WA -
61_evil_bias_nocross_10.txt WA -
61_evil_bias_nocross_11.txt WA -
61_evil_bias_nocross_12.txt AC 70 ms
20,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/scc>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<int(n);++i)
using lint=long long;

int main(){
    array<int,3>n;
    int m,ns=0;
    rep(i,3)cin>>n[i];
    rep(i,3)ns+=n[i];
    cin>>m;
    vector<int>u(m),v(m),st;
    rep(i,m){
        cin>>u[i]>>v[i];
        u[i]--;v[i]--;
        st.emplace_back(u[i]);
        st.emplace_back(v[i]);
    }
    st.emplace_back(ns);
    st.emplace_back(ns+1);
    sort(st.begin(),st.end());
    st.erase(unique(st.begin(),st.end()),st.end());
    int n2=st.size();
    vector<vector<pair<int,int>>> g(n2);
    scc_graph scc(n2);
    auto get=[&](int i){
        return lower_bound(st.begin(),st.end(),i)-st.begin();
    };
    //cerr<<n2<<endl;
    {
        int now=0,pre=0;
        rep(i,3){
            //cerr<<st[now]<<endl;
            if(st[now]>=pre+n[i]){
                //cerr<<"a"<<n[i]<<endl;
                g[n2-2].emplace_back(n2-1,n[i]+1);
                pre+=n[i];
                continue;
            }
            g[n2-2].emplace_back(now,st[now]+1-pre);
            while(1){
                if(now+1>=n2-2||st[now+1]>=pre+n[i])break;
                //cerr<<"tmp"<<endl;
                g[now].emplace_back(now+1,st[now+1]-st[now]);
                now++;
            }
            //cerr<<"pre"<<pre<<" "<<pre+n[i]-st[now]<<endl;
            g[now].emplace_back(n2-1,pre+n[i]-st[now]);
            now++;
            pre+=n[i];
        }
    }
    rep(i,m){
        g[get(u[i])].emplace_back(get(v[i]),1);
        g[get(v[i])].emplace_back(get(u[i]),1);
    }

    rep(i,n2){
        for(auto [e,c]:g[i]){
            scc.add_edge(i,e);
        }
    }
    auto res=scc.scc();
    int sz=res.size();
    //cerr<<sz<<endl;
    vector<vector<int>>g2(sz);
    vector<int>id(n2+2);
    vector<lint>v1(sz),v2(sz),v3(sz,1),v4(sz),v5(sz);
    rep(i,sz){
        for(auto s:res[i]){
            //cerr<<i<<" "<<s<<endl;
            id[s]=i;
        }
    }
    rep(i,n2){
        for(auto [e,c]:g[i]){
            if(id[i]==id[e])continue;
            if(id[e]==id[i]+1){
                //cerr<<"b"<<c<<endl;
                v3[id[i]]*=c;
                v4[id[i]]++;
                continue;
            }
            //cerr<<"c"<<c<<endl;
            v1[id[i]]+=c;
            v1[id[e]]-=c;
            v2[id[i]]+=c*c;
            v2[id[e]]-=c*c;
            v5[id[i]]++;
            v5[id[e]]--;
        }
    }
    lint ans=0,tmp=0,tmp2=0,tmp3=0;
    rep(i,sz-1){
        tmp+=v1[i];
        tmp2+=v2[i];
        tmp3+=v5[i];
        if(v4[i]+tmp3!=3)continue;
        //cerr<<tmp<<" "<<tmp2<<" "<<v3[i]<<" "<<v4[i]<<endl;
        if(v4[i]==1)ans+=(tmp*tmp-tmp2)/2*v3[i];
        else if(v4[i]==2)ans+=tmp*v3[i];
        else ans+=v3[i];
    }
    cout<<ans<<endl;
/**/}
0