結果
問題 | No.2160 みたりのDominator |
ユーザー | hotman78 |
提出日時 | 2022-12-08 15:16:54 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 423 ms / 2,000 ms |
コード長 | 4,937 bytes |
コンパイル時間 | 3,067 ms |
コンパイル使用メモリ | 232,336 KB |
実行使用メモリ | 35,504 KB |
最終ジャッジ日時 | 2024-10-14 13:07:38 |
合計ジャッジ時間 | 13,253 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 9 ms
7,936 KB |
testcase_02 | AC | 1 ms
5,248 KB |
testcase_03 | AC | 2 ms
5,248 KB |
testcase_04 | AC | 1 ms
5,248 KB |
testcase_05 | AC | 2 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 | 1 ms
5,248 KB |
testcase_12 | AC | 2 ms
5,248 KB |
testcase_13 | AC | 2 ms
5,248 KB |
testcase_14 | AC | 1 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 | 1 ms
5,248 KB |
testcase_22 | AC | 2 ms
5,248 KB |
testcase_23 | AC | 3 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 | 1 ms
5,248 KB |
testcase_30 | AC | 1 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 | 6 ms
7,936 KB |
testcase_35 | AC | 2 ms
5,248 KB |
testcase_36 | AC | 2 ms
5,248 KB |
testcase_37 | AC | 1 ms
5,248 KB |
testcase_38 | AC | 2 ms
5,248 KB |
testcase_39 | AC | 2 ms
5,248 KB |
testcase_40 | AC | 56 ms
12,160 KB |
testcase_41 | AC | 42 ms
11,264 KB |
testcase_42 | AC | 28 ms
8,192 KB |
testcase_43 | AC | 45 ms
10,496 KB |
testcase_44 | AC | 53 ms
12,028 KB |
testcase_45 | AC | 51 ms
12,284 KB |
testcase_46 | AC | 41 ms
11,264 KB |
testcase_47 | AC | 25 ms
8,192 KB |
testcase_48 | AC | 41 ms
10,368 KB |
testcase_49 | AC | 47 ms
12,032 KB |
testcase_50 | AC | 41 ms
11,776 KB |
testcase_51 | AC | 31 ms
8,704 KB |
testcase_52 | AC | 44 ms
10,880 KB |
testcase_53 | AC | 54 ms
12,032 KB |
testcase_54 | AC | 30 ms
8,320 KB |
testcase_55 | AC | 398 ms
34,212 KB |
testcase_56 | AC | 357 ms
32,380 KB |
testcase_57 | AC | 377 ms
32,152 KB |
testcase_58 | AC | 411 ms
35,264 KB |
testcase_59 | AC | 423 ms
34,200 KB |
testcase_60 | AC | 392 ms
34,492 KB |
testcase_61 | AC | 407 ms
34,484 KB |
testcase_62 | AC | 416 ms
35,504 KB |
testcase_63 | AC | 409 ms
34,264 KB |
testcase_64 | AC | 384 ms
33,720 KB |
testcase_65 | AC | 128 ms
16,112 KB |
testcase_66 | AC | 175 ms
18,724 KB |
testcase_67 | AC | 175 ms
18,760 KB |
testcase_68 | AC | 364 ms
32,052 KB |
testcase_69 | AC | 253 ms
24,536 KB |
testcase_70 | AC | 323 ms
30,252 KB |
testcase_71 | AC | 89 ms
12,772 KB |
testcase_72 | AC | 177 ms
20,936 KB |
testcase_73 | AC | 378 ms
33,036 KB |
testcase_74 | AC | 382 ms
32,676 KB |
testcase_75 | AC | 5 ms
6,400 KB |
testcase_76 | AC | 4 ms
5,888 KB |
testcase_77 | AC | 134 ms
17,300 KB |
testcase_78 | AC | 181 ms
20,796 KB |
testcase_79 | AC | 6 ms
5,248 KB |
testcase_80 | AC | 7 ms
5,376 KB |
testcase_81 | AC | 9 ms
7,168 KB |
testcase_82 | AC | 14 ms
7,936 KB |
testcase_83 | AC | 46 ms
10,624 KB |
61_evil_bias_nocross_01.txt | AC | 57 ms
12,216 KB |
61_evil_bias_nocross_02.txt | AC | 45 ms
11,008 KB |
61_evil_bias_nocross_03.txt | AC | 29 ms
8,184 KB |
61_evil_bias_nocross_04.txt | AC | 41 ms
10,420 KB |
61_evil_bias_nocross_05.txt | AC | 48 ms
11,692 KB |
61_evil_bias_nocross_06.txt | AC | 43 ms
11,652 KB |
61_evil_bias_nocross_07.txt | AC | 32 ms
8,960 KB |
61_evil_bias_nocross_08.txt | AC | 43 ms
10,752 KB |
61_evil_bias_nocross_09.txt | AC | 54 ms
12,028 KB |
61_evil_bias_nocross_10.txt | AC | 28 ms
8,184 KB |
61_evil_bias_nocross_11.txt | AC | 35 ms
9,444 KB |
61_evil_bias_nocross_12.txt | AC | 46 ms
11,152 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<int(n);++i) #define all(n) (n).begin(),(n).end() using lint=long long; array<vector<lint>,3>ng; array<vector<lint>,3>ok; array<vector<lint>,3>ok2; array<vector<lint>,3>rectx; array<vector<lint>,3>recty; array<vector<pair<lint,lint>>,3>judgex; array<vector<pair<lint,lint>>,3>judgey; vector<lint>v; void pre(){ int sz=rectx[2].size(); v.resize(sz); rep(i,sz-1){ if(ok2[2][i]){ v[i+1]=max(0LL,ok[1][rectx[2][i+1]]-ok[1][rectx[2][i]]) *max(0LL,ok[2][recty[2][i+1]]-ok[2][recty[2][i]]); } } rep(i,sz-1)v[i+1]+=v[i]; } lint get(lint l,lint r){ if(r<=l)return 0LL; return v[r]-v[l]; } lint getsum(lint p,lint q,lint r,lint s){ int sz=rectx[2].size(); lint ans=0; auto a=upper_bound(all(rectx[2]),p)-rectx[2].begin()-1; auto b=lower_bound(all(rectx[2]),q)-rectx[2].begin()-1; auto c=upper_bound(all(recty[2]),r)-recty[2].begin()-1; auto d=lower_bound(all(recty[2]),s)-recty[2].begin()-1; lint left=max(a,c),right=min(b,d); //cerr<<left<<" "<<right<<endl; { lint i=left; if(ok2[2][i]){ ans+=max(0LL,ok[1][min(q,rectx[2][i+1])]-ok[1][max(p,rectx[2][i])]) *max(0LL,ok[2][min(s,recty[2][i+1])]-ok[2][max(r,recty[2][i])]); } } if(left<right){ lint i=right; if(ok2[2][i]){ ans+=max(0LL,ok[1][min(q,rectx[2][i+1])]-ok[1][max(p,rectx[2][i])]) *max(0LL,ok[2][min(s,recty[2][i+1])]-ok[2][max(r,recty[2][i])]); } } ans+=get(left+1,right); return ans; } int main(){ array<lint,3>n; lint m; rep(i,3)cin>>n[i]; cin>>m; vector<lint>s(m),t(m),a(m),b(m),u(m),v(m); lint n1=n[0],n2=n[0]+n[1],n3=n[0]+n[1]+n[2]; rep(i,m){ cin>>u[i]>>v[i]; u[i]--;v[i]--; if(u[i]>v[i])swap(u[i],v[i]); if(u[i]==n3){ cout<<0<<endl; return 0; } if(u[i]<n1){ a[i]=u[i]+1; s[i]=0; }else if(u[i]<n2){ a[i]=u[i]-n1+1; s[i]=1; }else{ a[i]=u[i]-n2+1; s[i]=2; } if(v[i]==n3){ t[i]=s[i]; b[i]=0; }else if(v[i]==n3+1){ t[i]=s[i]; b[i]=n[s[i]]+1; }else if(v[i]<n1){ t[i]=0; b[i]=v[i]+1; }else if(v[i]<n2){ t[i]=1; b[i]=v[i]-n1+1; }else{ t[i]=2; b[i]=v[i]-n2+1; } } rep(i,3)n[i]++; //rep(i,3)cerr<<n[i]<<" \n"[i==2]; //rep(i,m)cerr<<s[i]<<" "<<t[i]<<" "<<a[i]<<" "<<b[i]<<endl; rep(i,3)ng[i].resize(n[i]+1); rep(i,3)ok[i].resize(n[i]+1); rep(i,3)rectx[i].emplace_back(0); rep(i,3)rectx[i].emplace_back(n[i==2]); rep(i,3)recty[i].emplace_back(0); rep(i,3)recty[i].emplace_back(n[2-(i==0)]); rep(i,m){ //cerr<<s[i]<<" "<<t[i]<<endl; if(s[i]==t[i]){ if(a[i]>b[i])swap(a[i],b[i]); ng[s[i]][a[i]]++; ng[t[i]][b[i]]--; }else{ if(s[i]>t[i]){ swap(s[i],t[i]); swap(a[i],b[i]); } int idx=s[i]+t[i]-1; rectx[idx].emplace_back(a[i]); recty[idx].emplace_back(b[i]); judgex[idx].emplace_back(a[i],i); judgey[idx].emplace_back(b[i],i); } } rep(i,3)rep(j,n[i])ng[i][j+1]+=ng[i][j]; rep(i,3)rep(j,n[i])ok[i][j+1]=(ng[i][j]==0); rep(i,3)rep(j,n[i])ok[i][j+1]+=ok[i][j]; rep(i,3)sort(all(rectx[i])); rep(i,3)sort(all(recty[i])); rep(i,3)sort(all(judgex[i])); rep(i,3)sort(all(judgey[i])); rep(i,3)ok2[i].resize(rectx[i].size()-1,0); rep(i,3){ ok2[i][0]=1; map<lint,lint>tmp; rep(j,judgex[i].size()){ tmp[judgex[i][j].second]++; tmp[judgey[i][j].second]--; if(tmp[judgex[i][j].second]==0)tmp.erase(judgex[i][j].second); if(tmp[judgey[i][j].second]==0)tmp.erase(judgey[i][j].second); if(tmp.size()==0){ ok2[i][j+1]=1; } //cerr<<tmp.size()<<endl; } } //rep(i,3)cout<<rectx[i].size()<<" \n"[i==2]; // rep(i,3)assert(rectx[i].size()==recty[i].size()); //rep(i,3)rep(j,ok[i].size()){ // cout<<ok[i][j]<<" \n"[j==ok[i].size()-1]; //} //cout<<endl;; //rep(i,3)rep(j,ok2[i].size()){ // cout<<ok2[i][j]<<" \n"[j==ok2[i].size()-1]; //} int id1=0,id2=0; lint ans=0; pre(); rep(i,n[0]){ if(ng[0][i])continue; while(i>=rectx[0][id1+1])id1++; while(i>=rectx[1][id2+1])id2++; if(!ok2[0][id1]||!ok2[1][id2])continue; ans+=getsum(recty[0][id1],recty[0][id1+1],recty[1][id2],recty[1][id2+1]); //cerr<<ans<<endl; } cout<<ans<<endl; /**/}