Submission #188105

#TimeUsernameProblemLanguageResultExecution timeMemory
188105anonymousVision Program (IOI19_vision)C++14
0 / 100
12 ms1656 KiB
#include "vision.h" #include<iostream> #define MAXN 205 using namespace std; int p[4]={2,3,5,7}, P=4; void construct_network(int H, int W, int K) { int HasR[MAXN], HasC[MAXN], modR[10][10], modC[10][10], modDR[10][10], modDC[10][10]; vector<int> R[MAXN], C[MAXN], gR[10][10], gC[10][10]; int distR[MAXN], distC[MAXN], filler; //generate whether each row and column has a black for (int r=0; r<H; r++) { for (int c=0; c<W; c++) { R[r].push_back(r*W+c); C[c].push_back(r*W+c); } } for (int i=0; i<H; i++) { HasR[i]=add_or(R[i]); } for (int i=0; i<W; i++) { HasC[i]=add_or(C[i]); } vector <int> Dummy; Dummy.push_back(HasC[0]); Dummy.push_back(add_not(HasC[0])); filler=add_and(Dummy); //guaranteed false if (H < 10) { for (int i=H; i<10; i++) { HasC[i]=filler; } H=10; } if (W < 10) { for (int i=W; i<10; i++) { HasR[i]=filler; } W=10; } //pad //generate position modulos for (int i=0; i<P; i++) { for (int r=0; r<H; r++) { gR[i][r%p[i]].push_back(HasR[r]); } } for (int i=0; i<P; i++) { for (int c=0; c<W; c++) { gC[i][c%p[i]].push_back(HasC[c]); } } for (int i=0; i<P; i++) { for (int mod=0; mod < p[i]; mod++) { modR[i][mod]=add_or(gR[i][mod]); modC[i][mod]=add_or(gC[i][mod]); } } //generate dist modulos for (int i=0; i<P; i++) { vector<int> Rpos; for (int mod=1; mod < p[i]; mod++) { vector <int> ask; for (int l=0; l<p[i]; l++) { vector <int> Pair; Pair.push_back(modR[i][l]); Pair.push_back(modR[i][(l+mod)%p[i]]); ask.push_back(add_and(Pair)); } modDR[i][mod]=add_or(ask); Rpos.push_back(modDR[i][mod]); } modDR[i][0]=add_not(add_or(Rpos)); } for (int i=0; i<P; i++) { vector<int> Cpos; for (int mod=1; mod < p[i]; mod++) { vector <int> ask; for (int l=0; l<p[i]; l++) { vector <int> Pair; Pair.push_back(modC[i][l]); Pair.push_back(modC[i][(l+mod)%p[i]]); ask.push_back(add_and(Pair)); } modDC[i][mod]=add_or(ask); Cpos.push_back(modDC[i][mod]); } modDC[i][0]=add_not(add_or(Cpos)); } //generate dists by CRT on dist modulos vector<int> Rlist, Clist; for (int i=1; i<H; i++) { vector<int> ask; for (int j=0; j<P; j++) { ask.push_back(modDR[j][i%p[j]]); } distR[i]=add_and(ask); Rlist.push_back(distR[i]); } distR[0]=add_not(add_or(Rlist)); for (int i=1; i<W; i++) { vector<int> ask; for (int j=0; j<P; j++) { ask.push_back(modDC[j][i%p[j]]); } distC[i]=add_and(ask); Clist.push_back(distC[i]); } distC[0]=add_not(add_or(Clist)); //generate answer vector <int> Res; for (int i=0; i<=K; i++) { vector <int> ask; if (i < H && K-i < W) { ask.push_back(distR[i]); ask.push_back(distC[K-i]); Res.push_back(add_and(ask)); } } add_or(Res); }
#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...