Submission #309819

#TimeUsernameProblemLanguageResultExecution timeMemory
309819AngelKnowsVision Program (IOI19_vision)C++14
100 / 100
38 ms5624 KiB
#include "vision.h" #include <bits/stdc++.h> using namespace std; #define FOR(i,n) for (int i=1;i<=n;i++) #define REP(i,a,b) for (int i=a;i<=b;i++) #define pb push_back #define fi first #define se second #define pi pair<int,int> #define mp make_pair typedef long long ll; const int inf=0x3f3f3f3f; const ll linf=1e18; const int N=40000+10; const double eps=1e-5; const int mo=1e9+7; vector<int> a,b,v,p,pos; int pos_a,pos_b,pos_l_a,pos_r_a,pos_l_b,pos_r_b; int c=-1,d=-1; int pos_r_k,pos_c_k,pos_dig=-1,pos_dig2=-1; vector<int> dig[N],dig2[N]; int l,r; void construct_network(int h, int w, int k) { for (int i=0;i<h;i++) { v.clear(); for (int j=0;j<w;j++) v.pb(i*w+j); a.pb(add_or(v)); } for (int j=0;j<w;j++) { v.clear(); for (int i=0;i<h;i++) v.pb(i*w+j); b.pb(add_or(v)); } pos_a=add_xor(a); pos_b=add_xor(b); v.clear(); for (int j=0;j<w;j++) { if (j+k>=w) break; v.pb(add_and(vector<int>{b[j],b[j+k]})); } if (!v.empty()) { c=add_or(v); pos.pb(add_and(vector<int>{c,pos_a})); } v.clear(); for (int i=0;i<h;i++) { if (i+k>=h) break; v.pb(add_and(vector<int>{a[i],a[i+k]})); } if (!v.empty()) { d=add_or(v); pos.pb(add_and(vector<int>{d,pos_b})); } p.clear(); for (int i=0;i<h;i++) { v.clear(); for (int i2=i;i2<=min(h-1,i+k);i2++) v.pb(a[i2]); p.pb(add_and(vector<int>{add_or(v),add_not(add_xor(v))})); } pos_r_k=add_or(p); p.clear(); for (int j=0;j<w;j++) { v.clear(); for (int j2=j;j2<=min(w-1,j+k);j2++) v.pb(b[j2]); p.pb(add_and(vector<int>{add_or(v),add_not(add_xor(v))})); } pos_c_k=add_or(p); for (int s=0;s<=h+w-2;s++) { //printf("%d\n",s); for (int i=0;i<h;i++) { int j=s-i; if (j<0||j>=w) continue; dig[s].pb(i*w+j); //printf("%d %d\n",i,j); } } v.clear(); for (int s=0;s<=h+w-2-k;s++) { v.pb(add_and(vector<int>{add_or(dig[s]),add_or(dig[s+k])})); } if (!v.empty()) pos_dig=add_or(v); for (int s=0;s<=h+w-2;s++) { //printf("%d\n",s); for (int i=0;i<h;i++) { int j=s-(h-1-i); if (j<0||j>=w) continue; dig2[s].pb(i*w+j); //printf("%d %d\n",i,j); } } v.clear(); for (int s=0;s<=h+w-2-k;s++) { v.pb(add_and(vector<int>{add_or(dig2[s]),add_or(dig2[s+k])})); } if (!v.empty()) pos_dig2=add_or(v); int t,t2=-1; if (pos_dig&&pos_dig2) t2=add_or(vector<int>{pos_dig,pos_dig2}); else if (pos_dig) t2=pos_dig; else if (pos_dig2) t2=pos_dig2; if (t2!=-1) t=add_and(vector<int>{add_not(pos_a),add_not(pos_b),t2,pos_c_k,pos_r_k}); else t=add_xor(vector<int>{0,0}); // 注定得到0 pos.pb(t); add_or(pos); return; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...