Submission #535419

#TimeUsernameProblemLanguageResultExecution timeMemory
535419mario05092929Vision Program (IOI19_vision)C++14
100 / 100
17 ms1916 KiB
#include "vision.h" #include <bits/stdc++.h> #define x first #define y second using namespace std; typedef long long ll; typedef pair <int,int> pi; int n,m,k,pl; int ad[405],su[405],adi[405],sui[405]; int ad_ori[405],su_ori[405]; int ad_or[405],su_or[405]; vector <int> adv[405], suv[405]; vector <int> mo; vector <int> check; vector <int> check2; int f(int x,int y) { return x*m+y; } int dist(int x1,int y1,int x2,int y2) { return abs(x1-x2)+abs(y1-y2); } void construct_network(int H, int W, int K) { n = H, m = W, k = K; int sx = -1,sy,st = n*m,en = n*m; for(int i = 0;i < n;i++) { for(int j = 0;j < m;j++) { suv[i-j+m].push_back(f(i,j)); adv[i+j+1].push_back(f(i,j)); } } for(int i = 1;i < n+m;i++) { su[i] = en; sui[i] = add_or(suv[i]); en++; } for(int i = 1;i < n+m;i++) { ad[i] = en; adi[i] = add_or(adv[i]); en++; } for(int i = 1;i < n+m;i++) { if(i > k) { check.push_back(en); add_and({su[i],su_or[i-k]}); en++; } if(i == 1) { su_or[i] = su[i]; su_ori[i] = sui[i]; } else { su_or[i] = en; su_ori[i] = add_or({su_or[i-1],su[i]}); en++; } } for(int i = 1;i < n+m;i++) { if(i > k) { check.push_back(en); add_and({ad[i],ad_or[i-k]}); en++; } if(i == 1) { ad_or[i] = ad[i]; ad_ori[i] = adi[i]; } else { ad_or[i] = en; ad_ori[i] = add_or({ad_or[i-1],ad[i]}); en++; } } memset(ad_or,0,sizeof(ad_or)); memset(su_or,0,sizeof(su_or)); for(int i = 1;i < n+m;i++) { if(i > k+1) { check2.push_back(en); add_and({su[i],su_or[i-k-1]}); en++; } if(i == 1) { su_or[i] = su[i]; su_ori[i] = sui[i]; } else { su_or[i] = en; su_ori[i] = add_or({su_or[i-1],su[i]}); en++; } } for(int i = 1;i < n+m;i++) { if(i > k+1) { check2.push_back(en); add_and({ad[i],ad_or[i-k-1]}); en++; } if(i == 1) { ad_or[i] = ad[i]; ad_ori[i] = adi[i]; } else { ad_or[i] = en; ad_ori[i] = add_or({ad_or[i-1],ad[i]}); en++; } } vector <int> ans; for(int i : check) ans.push_back(i); add_or(ans); en++; ans.clear(); if(!(int)check2.size()) return; for(int i : check2) ans.push_back(i); add_or(ans); en++; add_xor({en-2,en-1}); return; }

Compilation message (stderr)

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:27:9: warning: unused variable 'sx' [-Wunused-variable]
   27 |     int sx = -1,sy,st = n*m,en = n*m;
      |         ^~
vision.cpp:27:17: warning: unused variable 'sy' [-Wunused-variable]
   27 |     int sx = -1,sy,st = n*m,en = n*m;
      |                 ^~
vision.cpp:27:20: warning: unused variable 'st' [-Wunused-variable]
   27 |     int sx = -1,sy,st = n*m,en = n*m;
      |                    ^~
#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...