Submission #433765

#TimeUsernameProblemLanguageResultExecution timeMemory
433765MeGustaElArroz23Vision Program (IOI19_vision)C++14
44 / 100
23 ms8772 KiB
#include "vision.h" #include<bits/stdc++.h> using namespace std; #define fi first #define se second typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef pair<int,int> pii; typedef vector<pii> vii; typedef vector<vii> vvii; typedef vector<vvii> vvvii; int n; int m; vvi conexiones; void debug(vi v){ for (int x:v) cerr << x<<' '; cerr<<'\n'; } bool sirve(pii x){ if (x.first<0 or x.second<0 or x.first>=n or x.second>=m) return false; return true; } vi compressed_connections(vi v){ vector<bool> todos(n*m,false); for (int x:v){ for (int y:conexiones[x]) todos[y]=true; } vi res; for (int i=0;i<n*m;i++){ if (todos[i]) res.push_back(i); } return res; } void nope_construct_network(int H, int W, int k) { n=H; m=W; conexiones=vvi(n*m); for (int i=0;i<n;i++){ for (int j=0;j<m;j++){ for (int x=0;x<=k;x++){ if (sirve(pii{i+x,j+(k-x)})) conexiones[m*i+j].push_back(m*(i+x)+j+(k-x)); if (sirve(pii{i-x,j+(k-x)})) conexiones[m*i+j].push_back(m*(i-x)+j+(k-x)); if (sirve(pii{i+x,j-(k-x)})) conexiones[m*i+j].push_back(m*(i+x)+j-(k-x)); if (sirve(pii{i-x,j-(k-x)})) conexiones[m*i+j].push_back(m*(i-x)+j-(k-x)); } } } for (int i=0;i<9;i++) debug(conexiones[i]); //debug(conexiones[0]); //debug(conexiones[1]); //debug(conexiones[5]); vi aux(n*m); for (int i=0;i<n*m;i++) aux[i]=i; int donde_true=add_or(aux); int maxpot=1; while (k%maxpot==0) maxpot*=2; vvi necesita(n*m); int pot=2; while (pot/2<n*m-1){ vi v1; vi v2; for (int i=0;i<n*m;i++){ if ((i/m+i%m)%maxpot<maxpot/2) continue; if (i%pot<pot/2) v1.push_back(i); else v2.push_back(i); } //debug(v1); //debug(v2); int a; if (v1.size()) a=add_or(v1); else a=add_not(donde_true); cerr << a << " : "; debug(v1); for (int i:v1){ necesita[i].push_back(a); } //vi g=compressed_connections(v1); //debug(compressed_connections(v1)); if (compressed_connections(v1).size()) a=add_or(compressed_connections(v1)); else a=add_not(donde_true); cerr << a << " : "; debug(compressed_connections(v1)); for (int i:v1){ necesita[i].push_back(a); } if (v2.size()) a=add_or(v2); else a=add_not(donde_true); cerr << a << " : "; debug(v2); for (int i:v2){ if (i%pot>=pot/2) necesita[i].push_back(a); } if (compressed_connections(v2).size()) a=add_or(compressed_connections(v2)); else a=add_not(donde_true); cerr << a << " : "; debug(compressed_connections(v2)); for (int i:v2){ if (i%pot>=pot/2) necesita[i].push_back(a); } pot*=2; } for (int i=0;i<n*m;i++){ cerr << i << ": "; debug(necesita[i]); } vi ac; for (int i=0;i<n*m;i++){ if ((i/m+i%m)%maxpot<maxpot/2) continue; ac.push_back(add_and(necesita[i])); } //cerr<<"a"; //debug(ac); add_or(ac); } void construct_network(int H, int W, int k){ n=H; m=W; conexiones=vvi(n*m); for (int i=0;i<n;i++){ for (int j=0;j<m;j++){ for (int x=0;x<=k;x++){ if (sirve(pii{i+x,j+(k-x)})) conexiones[m*i+j].push_back(m*(i+x)+j+(k-x)); if (sirve(pii{i-x,j+(k-x)})) conexiones[m*i+j].push_back(m*(i-x)+j+(k-x)); if (sirve(pii{i+x,j-(k-x)})) conexiones[m*i+j].push_back(m*(i+x)+j-(k-x)); if (sirve(pii{i-x,j-(k-x)})) conexiones[m*i+j].push_back(m*(i-x)+j-(k-x)); } } } vi ac; for (int i=0;i<n*m;i++){ if (conexiones[i].size()) ac.push_back(add_and(vi{add_and(vi{i}),add_or(conexiones[i])})); } add_or(ac); }
#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...