Submission #422920

#TimeUsernameProblemLanguageResultExecution timeMemory
422920yuto1115Vision Program (IOI19_vision)C++17
100 / 100
47 ms1920 KiB
#include "vision.h" #include <bits/stdc++.h> #define rep(i, n) for(ll i = 0; i < ll(n); i++) #define rep2(i, s, n) for(ll i = ll(s); i < ll(n); i++) #define rrep(i, n) for(ll i = ll(n)-1; i >= 0; i--) #define pb push_back #define eb emplace_back #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() using namespace std; using ll = long long; using P = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vp = vector<P>; using vvp = vector<vp>; using vb = vector<bool>; using vvb = vector<vb>; using vs = vector<string>; const int inf = 1001001001; const ll linf = 1001001001001001001; template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } void construct_network(int h, int w, int k) { int s = h + w - 1; vi tmp; rep(i, h) rep(j, w) tmp.pb(i * w + j); int F1 = add_or(tmp); int F0 = add_not(F1); auto get = [&](int i, int j) -> int { assert(0 <= i and i < 13); if (i < 12) assert(0 <= j and j < s); else assert(0 <= j and j < 8); return h * w + 2 + s * i + j; }; // r + c { rep(i, s) { vi ls; rep(r, h) rep(c, w) { if (r + c == i) ls.pb(r * w + c); } add_or(ls); } rep(i, s) add_not(get(0, i)); add_or({get(0, 0)}); rep2(i, 1, s) add_or({get(2, i - 1), get(0, i)}); rep(i, s) add_not(get(2, i)); rep(i, s) { if (i > k) { add_or({get(1, i), get(3, i - k - 1)}); } else { add_not(F0); } }; rep(i, s) { if (i >= k) { add_or({get(1, i), get(3, i - k)}); } else { add_not(F0); } }; } // r - c { rep2(i, -w + 1, h) { vi ls; rep(r, h) rep(c, w) { if (r - c == i) ls.pb(r * w + c); } add_or(ls); } rep(i, s) add_not(get(6, i)); add_or({get(6, 0)}); rep2(i, 1, s) add_or({get(8, i - 1), get(6, i)}); rep(i, s) add_not(get(8, i)); rep(i, s) { if (i > k) { add_or({get(7, i), get(9, i - k - 1)}); } else { add_not(F0); } }; rep(i, s) { if (i >= k) { add_or({get(7, i), get(9, i - k)}); } else { add_not(F0); } }; } tmp.clear(); rep(i, s) tmp.pb(get(4, i)); add_and(tmp); tmp.clear(); rep(i, s) tmp.pb(get(10, i)); add_and(tmp); tmp.clear(); rep(i, s) tmp.pb(get(5, i)); add_and(tmp); tmp.clear(); rep(i, s) tmp.pb(get(11, i)); add_and(tmp); add_and({get(12, 0), get(12, 1)}); add_and({get(12, 2), get(12, 3)}); add_not(get(12, 5)); add_and({get(12, 4), get(12, 6)}); }
#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...