結果

問題 No.2160 みたりのDominator
ユーザー hotman78hotman78
提出日時 2022-12-08 13:19:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,568 bytes
コンパイル時間 3,235 ms
コンパイル使用メモリ 234,016 KB
実行使用メモリ 80,988 KB
最終ジャッジ日時 2024-04-22 12:04:30
合計ジャッジ時間 19,188 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,820 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
6,940 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 3 ms
6,944 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 3 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 AC 2 ms
6,948 KB
testcase_31 AC 2 ms
6,944 KB
testcase_32 AC 2 ms
6,940 KB
testcase_33 AC 2 ms
6,944 KB
testcase_34 AC 1 ms
6,940 KB
testcase_35 AC 2 ms
6,944 KB
testcase_36 AC 2 ms
6,940 KB
testcase_37 AC 2 ms
6,940 KB
testcase_38 AC 2 ms
6,940 KB
testcase_39 AC 2 ms
6,944 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 AC 541 ms
48,060 KB
testcase_56 AC 414 ms
30,604 KB
testcase_57 AC 452 ms
35,276 KB
testcase_58 AC 490 ms
40,568 KB
testcase_59 AC 451 ms
36,120 KB
testcase_60 AC 368 ms
25,036 KB
testcase_61 AC 516 ms
45,760 KB
testcase_62 AC 562 ms
53,572 KB
testcase_63 AC 535 ms
47,604 KB
testcase_64 AC 340 ms
26,688 KB
testcase_65 AC 222 ms
41,928 KB
testcase_66 AC 294 ms
44,508 KB
testcase_67 AC 301 ms
45,708 KB
testcase_68 AC 615 ms
78,688 KB
testcase_69 AC 470 ms
58,192 KB
testcase_70 AC 649 ms
80,988 KB
testcase_71 AC 156 ms
31,980 KB
testcase_72 AC 355 ms
59,020 KB
testcase_73 AC 618 ms
71,136 KB
testcase_74 AC 603 ms
67,724 KB
testcase_75 AC 2 ms
6,940 KB
testcase_76 AC 2 ms
6,940 KB
testcase_77 AC 233 ms
45,344 KB
testcase_78 AC 322 ms
55,844 KB
testcase_79 AC 10 ms
6,940 KB
testcase_80 AC 13 ms
6,940 KB
testcase_81 AC 11 ms
6,944 KB
testcase_82 AC 27 ms
9,316 KB
testcase_83 AC 64 ms
15,072 KB
61_evil_bias_nocross_01.txt WA -
61_evil_bias_nocross_02.txt WA -
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 WA -
61_evil_bias_nocross_07.txt WA -
61_evil_bias_nocross_08.txt WA -
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 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/scc>
#include<atcoder/dsu>
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]){
                g[n2-2].emplace_back(n2-1,n[i]+1);
                pre+=n[i];
                continue;
            }
            g[n2-2].emplace_back(now,st[now]-pre+1);
            while(1){
                if(st[now+1]-pre>=n[i])break;
                g[now].emplace_back(now+1,(st[now+1]-pre+1)-(st[now]-pre+1));
                now++;
            }
            g[now].emplace_back(n2-1,(n[i]+1)-(st[now]-pre+1));
            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();
    vector<vector<pair<lint,lint>>>g2(sz);
    vector<int>id(n2);
    rep(i,sz){
        for(auto s:res[i]){
            id[s]=i;
        }
    }
    rep(j,sz){
        map<lint,lint>l;
        for(auto i:res[j]){
            for(auto [e,c]:g[i]){
                if(id[i]==id[e])continue;
                if(l[id[e]]==0)l[id[e]]=1;
                l[id[e]]*=c;
            }
        }
        for(auto [e,c]:l){
            g2[j].emplace_back(e,c);
        }
    }
    lint ans=0,tmp=1;
    vector<lint>div(sz,1);
    rep(i,sz-1){
        if(g2[i].size()==1&&i!=0)continue;
        tmp/=div[i];
        for(auto [e,c]:g2[i]){
            lint to=e;
            while(g2[to].size()==1){
                c+=g2[to][0].second;
                to=g2[to][0].first;
            }
            //cerr<<e<<c<<endl;
            tmp*=c;
            div[to]*=c;
        }
        //cerr<<tmp<<endl;
        ans+=tmp;
    }
    cout<<ans<<endl;
/**/}
0