Submission #283266

#TimeUsernameProblemLanguageResultExecution timeMemory
283266KastandaVision Program (IOI19_vision)C++14
100 / 100
20 ms1664 KiB
// M #include<bits/stdc++.h> #include "vision.h" #define pb push_back using namespace std; struct Data {vector < int > v;}; int Zero = -1; inline Data Add(Data a, Data b) { assert(Zero != -1); Data d; int carry = Zero; if (a.v.size() > b.v.size()) swap(a, b); while (a.v.size() < b.v.size()) a.v.pb(Zero); for (int i = 0; i < (int)a.v.size(); i ++) { d.v.pb(add_xor(vector < int > {a.v[i], b.v[i], carry})); int tmp1 = add_and(vector < int > {a.v[i], b.v[i]}); int tmp2 = add_and(vector < int > {a.v[i], carry}); int tmp3 = add_and(vector < int > {carry, b.v[i]}); carry = add_or(vector < int > {tmp1, tmp2, tmp3}); } d.v.pb(carry); return d; } void construct_network(int n, int m, int k) { vector < Data > D; for (int i = 0, last = -1; i < n; i ++) { vector < int > vec; if (i) vec.pb(last); for (int j = 0; j < m; j ++) vec.pb(i * m + j); last = add_xor(vec); D.pb(Data { vector < int > {last} }); if (i == n - 1) Zero = last; } for (int j = 0, last = -1; j < m; j ++) { vector < int > vec; if (j) vec.pb(last); for (int i = 0; i < n; i ++) vec.pb(i * m + j); last = add_xor(vec); D.pb(Data { vector < int > {last} }); } while (D.size() > 1) { vector < Data > D2; for (int i = 1; i < (int)D.size(); i += 2) D2.pb(Add(D[i - 1], D[i])); if (D.size() & 1) D2.pb(D.back()); D.swap(D2); } Data d = D[0]; vector < int > vec; for (int i = 0; i < (int)d.v.size(); i ++) if (k >> i & 1) vec.pb(d.v[i]); else vec.pb(add_not(d.v[i])); add_and(vec); return ; }
#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...