結果
問題 | No.2160 みたりのDominator |
ユーザー | tko919 |
提出日時 | 2022-12-23 12:13:59 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 268 ms / 2,000 ms |
コード長 | 7,030 bytes |
コンパイル時間 | 2,785 ms |
コンパイル使用メモリ | 214,812 KB |
実行使用メモリ | 66,448 KB |
最終ジャッジ日時 | 2024-11-18 03:59:14 |
合計ジャッジ時間 | 14,741 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 87 ms
50,724 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | AC | 2 ms
5,248 KB |
testcase_04 | AC | 2 ms
5,248 KB |
testcase_05 | AC | 3 ms
5,248 KB |
testcase_06 | AC | 2 ms
5,248 KB |
testcase_07 | AC | 2 ms
5,248 KB |
testcase_08 | AC | 2 ms
5,248 KB |
testcase_09 | AC | 2 ms
5,248 KB |
testcase_10 | AC | 2 ms
5,248 KB |
testcase_11 | AC | 2 ms
5,248 KB |
testcase_12 | AC | 2 ms
5,248 KB |
testcase_13 | AC | 2 ms
5,248 KB |
testcase_14 | AC | 2 ms
5,248 KB |
testcase_15 | AC | 2 ms
5,248 KB |
testcase_16 | AC | 2 ms
5,248 KB |
testcase_17 | AC | 2 ms
5,248 KB |
testcase_18 | AC | 2 ms
5,248 KB |
testcase_19 | AC | 2 ms
5,248 KB |
testcase_20 | AC | 2 ms
5,248 KB |
testcase_21 | AC | 2 ms
5,248 KB |
testcase_22 | AC | 2 ms
5,248 KB |
testcase_23 | AC | 2 ms
5,248 KB |
testcase_24 | AC | 2 ms
5,248 KB |
testcase_25 | AC | 2 ms
5,248 KB |
testcase_26 | AC | 2 ms
5,248 KB |
testcase_27 | AC | 2 ms
5,248 KB |
testcase_28 | AC | 2 ms
5,248 KB |
testcase_29 | AC | 2 ms
5,248 KB |
testcase_30 | AC | 2 ms
5,248 KB |
testcase_31 | AC | 2 ms
5,248 KB |
testcase_32 | AC | 2 ms
5,248 KB |
testcase_33 | AC | 2 ms
5,248 KB |
testcase_34 | AC | 95 ms
66,448 KB |
testcase_35 | AC | 2 ms
5,248 KB |
testcase_36 | AC | 2 ms
5,248 KB |
testcase_37 | AC | 2 ms
5,248 KB |
testcase_38 | AC | 2 ms
5,248 KB |
testcase_39 | AC | 2 ms
5,248 KB |
testcase_40 | AC | 134 ms
45,044 KB |
testcase_41 | AC | 121 ms
45,232 KB |
testcase_42 | AC | 70 ms
28,072 KB |
testcase_43 | AC | 100 ms
34,540 KB |
testcase_44 | AC | 129 ms
43,528 KB |
testcase_45 | AC | 120 ms
40,056 KB |
testcase_46 | AC | 103 ms
37,396 KB |
testcase_47 | AC | 57 ms
21,760 KB |
testcase_48 | AC | 75 ms
25,076 KB |
testcase_49 | AC | 94 ms
29,516 KB |
testcase_50 | AC | 87 ms
29,688 KB |
testcase_51 | AC | 78 ms
31,220 KB |
testcase_52 | AC | 113 ms
41,612 KB |
testcase_53 | AC | 127 ms
42,988 KB |
testcase_54 | AC | 70 ms
26,328 KB |
testcase_55 | AC | 208 ms
37,072 KB |
testcase_56 | AC | 120 ms
31,776 KB |
testcase_57 | AC | 153 ms
33,456 KB |
testcase_58 | AC | 209 ms
48,408 KB |
testcase_59 | AC | 167 ms
37,492 KB |
testcase_60 | AC | 94 ms
48,636 KB |
testcase_61 | AC | 200 ms
35,324 KB |
testcase_62 | AC | 260 ms
50,328 KB |
testcase_63 | AC | 218 ms
38,976 KB |
testcase_64 | AC | 71 ms
37,108 KB |
testcase_65 | AC | 132 ms
33,624 KB |
testcase_66 | AC | 130 ms
28,116 KB |
testcase_67 | AC | 146 ms
29,792 KB |
testcase_68 | AC | 268 ms
45,304 KB |
testcase_69 | AC | 191 ms
34,156 KB |
testcase_70 | AC | 266 ms
46,120 KB |
testcase_71 | AC | 102 ms
31,332 KB |
testcase_72 | AC | 209 ms
46,956 KB |
testcase_73 | AC | 240 ms
37,412 KB |
testcase_74 | AC | 225 ms
34,960 KB |
testcase_75 | AC | 42 ms
31,968 KB |
testcase_76 | AC | 34 ms
25,840 KB |
testcase_77 | AC | 174 ms
47,900 KB |
testcase_78 | AC | 200 ms
48,044 KB |
testcase_79 | AC | 25 ms
18,380 KB |
testcase_80 | AC | 31 ms
20,396 KB |
testcase_81 | AC | 55 ms
35,748 KB |
testcase_82 | AC | 67 ms
38,216 KB |
testcase_83 | AC | 81 ms
31,636 KB |
61_evil_bias_nocross_01.txt | AC | 127 ms
44,988 KB |
61_evil_bias_nocross_02.txt | AC | 122 ms
45,472 KB |
61_evil_bias_nocross_03.txt | AC | 63 ms
28,072 KB |
61_evil_bias_nocross_04.txt | AC | 87 ms
34,428 KB |
61_evil_bias_nocross_05.txt | AC | 115 ms
43,600 KB |
61_evil_bias_nocross_06.txt | AC | 123 ms
45,440 KB |
61_evil_bias_nocross_07.txt | AC | 78 ms
31,132 KB |
61_evil_bias_nocross_08.txt | AC | 112 ms
41,608 KB |
61_evil_bias_nocross_09.txt | AC | 109 ms
43,116 KB |
61_evil_bias_nocross_10.txt | AC | 63 ms
26,452 KB |
61_evil_bias_nocross_11.txt | AC | 85 ms
34,040 KB |
61_evil_bias_nocross_12.txt | AC | 113 ms
38,968 KB |
ソースコード
#line 1 "library/Template/template.hpp" #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define ALL(v) (v).begin(),(v).end() using ll=long long int; const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;} template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;} #line 2 "library/Utility/fastio.hpp" #include <unistd.h> class FastIO{ static constexpr int L=1<<16; char rdbuf[L]; int rdLeft=0,rdRight=0; inline void reload(){ int len=rdRight-rdLeft; memmove(rdbuf,rdbuf+rdLeft,len); rdLeft=0,rdRight=len; rdRight+=fread(rdbuf+len,1,L-len,stdin); } inline bool skip(){ for(;;){ while(rdLeft!=rdRight and rdbuf[rdLeft]<=' ')rdLeft++; if(rdLeft==rdRight){ reload(); if(rdLeft==rdRight)return false; } else break; } return true; } template<typename T,enable_if_t<is_integral<T>::value,int> =0>inline bool _read(T& x){ if(!skip())return false; if(rdLeft+20>=rdRight)reload(); bool neg=false; if(rdbuf[rdLeft]=='-'){ neg=true; rdLeft++; } x=0; while(rdbuf[rdLeft]>='0' and rdLeft<rdRight){ x=x*10+(neg?-(rdbuf[rdLeft++]^48):(rdbuf[rdLeft++]^48)); } return true; } template<typename T,enable_if_t<is_floating_point<T>::value,int> =0>inline bool _read(T& x){ if(!skip())return false; if(rdLeft+20>=rdRight)reload(); bool neg=false; if(rdbuf[rdLeft]=='-'){ neg=true; rdLeft++; } x=0; while(rdbuf[rdLeft]>='0' and rdbuf[rdLeft]<='9' and rdLeft<rdRight){ x=x*10+(rdbuf[rdLeft++]^48); } if(rdbuf[rdLeft]!='.')return true; rdLeft++; T base=.1; while(rdbuf[rdLeft]>='0' and rdbuf[rdLeft]<='9' and rdLeft<rdRight){ x+=base*(rdbuf[rdLeft++]^48); base*=.1; } if(neg)x=-x; return true; } inline bool _read(char& x){ if(!skip())return false; if(rdLeft+1>=rdRight)reload(); x=rdbuf[rdLeft++]; return true; } inline bool _read(string& x){ if(!skip())return false; for(;;){ int pos=rdLeft; while(pos<rdRight and rdbuf[pos]>' ')pos++; x.append(rdbuf+rdLeft,pos-rdLeft); if(rdLeft==pos)break; rdLeft=pos; if(rdLeft==rdRight)reload(); else break; } return true; } template<typename T>inline bool _read(vector<T>& v){ for(auto& x:v){ if(!_read(x))return false; } return true; } char wtbuf[L],tmp[50]; int wtRight=0; inline void flush(){ fwrite(wtbuf,1,wtRight,stdout); wtRight=0; } inline void _write(const char& x){ if(wtRight>L-32)flush(); wtbuf[wtRight++]=x; } inline void _write(const string& x){ for(auto& c:x)_write(c); } template<typename T,enable_if_t<is_integral<T>::value,int> =0>inline void _write(T x){ if(wtRight>L-32)flush(); if(x==0){ _write('0'); return; } else if(x<0){ _write('-'); if (__builtin_expect(x == std::numeric_limits<T>::min(), 0)) { switch (sizeof(x)) { case 2: _write("32768"); return; case 4: _write("2147483648"); return; case 8: _write("9223372036854775808"); return; } } x=-x; } int pos=0; while(x!=0){ tmp[pos++]=char((x%10)|48); x/=10; } rep(i,0,pos)wtbuf[wtRight+i]=tmp[pos-1-i]; wtRight+=pos; } template<typename T>inline void _write(const vector<T>& v){ rep(i,0,v.size()){ if(i)_write(' '); _write(v[i]); } } public: FastIO(){} ~FastIO(){flush();} inline void read(){} template <typename Head, typename... Tail>inline void read(Head& head,Tail&... tail){ assert(_read(head)); read(tail...); } template<bool ln=true,bool space=false>inline void write(){if(ln)_write('\n');} template <bool ln=true,bool space=false,typename Head, typename... Tail>inline void write(const Head& head,const Tail&... tail){ if(space)_write(' '); _write(head); write<ln,true>(tail...); } }; /** * @brief Fast IO */ #line 3 "sol.cpp" #line 2 "library/Graph/scc.hpp" struct SCC{ int n,m,cur; vector<vector<int>> g; vector<int> low,ord,id; SCC(int _n=0):n(_n),m(0),cur(0),g(_n),low(_n),ord(_n,-1),id(_n){} void resize(int _n){ n=_n; g.resize(n); low.resize(n); ord.resize(n,-1); id.resize(n); } void add_edge(int u,int v){g[u].emplace_back(v);} void dfs(int v,vector<int>& used){ ord[v]=low[v]=cur++; used.emplace_back(v); for(auto& nxt:g[v]){ if(ord[nxt]==-1){ dfs(nxt,used); chmin(low[v],low[nxt]); } else{ chmin(low[v],ord[nxt]); } } if(ord[v]==low[v]){ while(1){ int add=used.back(); used.pop_back(); ord[add]=n; id[add]=m; if(v==add)break; } m++; } } void run(){ vector<int> used; rep(v,0,n)if(ord[v]==-1)dfs(v,used); for(auto& x:id)x=m-1-x; } }; /** * @brief Strongly Connected Components */ #line 5 "sol.cpp" FastIO io; int main(){ int n[3],m; rep(i,0,3)io.read(n[i]); io.read(m); int N=n[0]+n[1]+n[2]+2; int s=N-2,t=N-1; SCC scc(N); int offset=0; rep(i,0,3){ if(n[i]){ scc.add_edge(s,offset); scc.add_edge(offset+n[i]-1,t); rep(j,0,n[i]-1)scc.add_edge(offset+j,offset+j+1); } else scc.add_edge(s,t); offset+=n[i]; } rep(_,0,m){ int u,v; io.read(u,v); u--; v--; scc.add_edge(u,v); scc.add_edge(v,u); } scc.run(); int N2=scc.m; s=scc.id[s],t=scc.id[t]; if(s==t){ io.write(0); return 0; } vector g2(N2,vector<int>()); vector<int> cnt(N2); rep(u,0,N)for(auto& v:scc.g[u])if(scc.id[u]!=scc.id[v]){ g2[scc.id[u]].push_back(scc.id[v]); cnt[scc.id[u]]++; cnt[scc.id[v]]++; } vector<ll> add(N2,1); rep(v,0,N2)if(cnt[v]!=2){ for(auto& to:g2[v]){ int nxt=to,w=1; while(cnt[nxt]==2)nxt=g2[nxt][0],w++; rep(x,v,nxt)add[x]*=w; } } ll ret=0; rep(x,0,N2-1)if(cnt[x]!=2)ret+=add[x]; io.write(ret); return 0; }