Submission #1242684

#TimeUsernameProblemLanguageResultExecution timeMemory
1242684nvujicaVision Program (IOI19_vision)C++20
100 / 100
13 ms2628 KiB
#include <bits/stdc++.h> #include "vision.h" using namespace std; const int maxn = 210, BIT = 9; int h, w; int red[maxn][2]; int stu[maxn][2]; int br[2 * maxn]; int cnt[BIT]; int cnt2[BIT]; int pref[BIT]; int raz[BIT]; vector <int> v; void OR(){ for(int i = 0; i < h; i++){ v.clear(); if(i) v.push_back(red[i - 1][0]); for(int j = 0; j < w; j++){ v.push_back(i * w + j); } red[i][0] = add_or(v); } for(int j = 0; j < w; j++){ v.clear(); if(j) v.push_back(stu[j - 1][0]); for(int i = 0; i < h; i++){ v.push_back(i * w + j); } stu[j][0] = add_or(v); } } void XOR(){ for(int i = 0; i < h; i++){ v.clear(); if(i) v.push_back(red[i - 1][1]); for(int j = 0; j < w; j++){ v.push_back(i * w + j); } red[i][1] = add_xor(v); } for(int j = 0; j < w; j++){ v.clear(); if(j) v.push_back(stu[j - 1][1]); for(int i = 0; i < h; i++){ v.push_back(i * w + j); } stu[j][1] = add_xor(v); } } void construct_network(int H, int W, int k) { h = H; w = W; // Ns = {0, 1}; // int a = add_and(Ns); // Ns = {0, a}; // int b = add_or(Ns); // Ns = {0, 1, b}; // int c = add_xor(Ns); // add_not(c); int nula = add_xor({0, 0}); int jedan = add_not(nula); // cout << nula << ' ' << jedan << endl; // cout << "stigo" << endl; OR(); XOR(); for(int i = 0; i < h; i++){ br[i] = add_and({red[i][0], red[i][1]}); } for(int j = 0; j < w; j++){ br[h + j] = add_and({stu[j][0], stu[j][1]}); } // for(int i = 0; i < BIT; i++){ // if(k & (1 << i)) cnt[i] = add_not(nula); // else cnt[i] = add_not(jedan); // } for(int i = 0; i < BIT; i++){ cnt[i] = add_and({nula}); } for(int t = 0; t < h + w; t++){ // for(int i = 0; i < BIT; i++){ // if(!i) pref[0] = add_and({jedan}); // else pref[i] = add_and({pref[i - 1], cnt[i - 1]}); // } v.clear(); v.push_back(br[t]); for(int i = 0; i < BIT; i++){ if(i) v.push_back({cnt[i - 1]}); cnt2[i] = add_xor({cnt[i], add_and(v)}); } for(int i = 0; i < BIT; i++){ cnt[i] = cnt2[i]; } } for(int i = 0; i < BIT; i++){ if(k & (1 << i)) raz[i] = add_xor({cnt[i], jedan}); else raz[i] = add_xor({cnt[i], nula}); } v.clear(); for(int i = 0; i < BIT; i++){ v.push_back(raz[i]); } int ans = add_or(v); add_not(ans); // cout << "stigo" << endl; }
#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...