Submission #612329

#TimeUsernameProblemLanguageResultExecution timeMemory
612329dnassVision Program (IOI19_vision)C++17
100 / 100
51 ms4444 KiB
#include "vision.h" #include <bits/stdc++.h> using namespace std; #define ff first #define ss second int h,w,k; int diag_left[410]; int diag_right[410]; int lk, rk, lbl, rbl; pair<int,int> ltog(int x){ return {x/w, x%w}; } int gtol(int x, int y){ return x*w+y; } bool inside(int x, int y){ return (x>=0&&x<h&&y>=0&&y<w); } void construct_network(int H, int W, int K) { h = H; w = W; k = K; if(k==h+w-2){ add_or({add_and({gtol(0,0), gtol(h-1,w-1)}), add_and({gtol(0,w-1),gtol(h-1,0)})}); return; } for(int diag=0;diag<h+w-1;diag++){ vector<int> query; if(diag<w){ for(int i=0,j=diag;inside(i,j);i++,j--){ query.push_back(gtol(i,j)); } }else{ for(int i=diag-w+1,j=w-1;inside(i,j);i++,j--){ query.push_back(gtol(i,j)); } } diag_left[diag] = add_or(query); } for(int diag=0;diag<h+w-1;diag++){ vector<int> query; if(diag<h){ for(int i=h-1-diag,j=0;inside(i,j);i++,j++){ query.push_back(gtol(i,j)); } }else{ for(int i=0,j=diag-h+1;inside(i,j);i++,j++){ query.push_back(gtol(i,j)); } } diag_right[diag] = add_or(query); } vector<int> leftk, rightk; for(int i=0;i+k<h+w-1;i++){ leftk.push_back(add_and({diag_left[i],diag_left[i+k]})); rightk.push_back(add_and({diag_right[i],diag_right[i+k]})); } lk = add_or(leftk); rk = add_or(rightk); vector<int> lblock, rblock; for(int diag=0;diag+k<h+w-1;diag++){ vector<int> ql, qr; for(int i=0;i<h+w-1;i++){ if(diag<=i&&i<=diag+k) continue; ql.push_back(diag_left[i]); qr.push_back(diag_right[i]); } lblock.push_back(add_not(add_or(ql))); rblock.push_back(add_not(add_or(qr))); } lbl = add_or(lblock); rbl = add_or(rblock); add_or({add_and({lk, rbl}), add_and({rk, lbl})}); }
#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...