Submission #144405

#TimeUsernameProblemLanguageResultExecution timeMemory
144405qkxwsmVision Program (IOI19_vision)C++14
100 / 100
28 ms3068 KiB
#include "vision.h" #include <bits/stdc++.h> using namespace std; template<class T, class U> void ckmin(T &a, U b) { if (a > b) a = b; } template<class T, class U> void ckmax(T &a, U b) { if (a < b) a = b; } #define MP make_pair #define PB push_back #define LB lower_bound #define UB upper_bound #define fi first #define se second #define FOR(i, a, b) for (auto i = (a); i < (b); i++) #define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--) #define SZ(x) ((int) (x).size()) #define ALL(x) (x).begin(), (x).end() typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpi; typedef vector<pll> vpl; int N, M, K, C, S[15]; vi tmp; void construct_network(int n, int m, int k) { //you want to see if the two squares with 1 are at distance K N = n; M = m; K = k; C = N * M; S[0] = C; FOR(i, 0, N + M - 1) { tmp.clear(); FOR(x, 0, N) { int y = i - x; if (y < 0 || y >= M) continue; tmp.PB(x * M + y); } add_or(tmp); C++; } S[1] = C; FOR(i, -(M - 1), N) { tmp.clear(); FOR(x, 0, N) { int y = x - i; if (y < 0 || y >= M) continue; tmp.PB(x * M + y); } add_or(tmp); C++; } S[2] = C; FOR(i, K, N + M - 1) { tmp.clear(); tmp.PB(i + S[0]); tmp.PB((i - K) + S[0]); add_and(tmp); C++; } S[3] = C; FOR(i, -(M - 1) + K, N) { tmp.clear(); tmp.PB(i + (M - 1) + S[1]); tmp.PB(i + (M - 1 - K) + S[1]); add_and(tmp); C++; } S[4] = C; tmp.clear(); FOR(i, S[2], S[4]) { tmp.PB(i); } add_or(tmp); C++; S[5] = C; //we need to make sure there's NOTHING strictly greater than K //precompute prefixes for x+ys tmp.clear(); FOR(i, 0, N + M - 1) { tmp.PB(i + S[0]); add_or(tmp); C++; } S[6] = C; //precompute prefixes for x-ys tmp.clear(); FOR(i, (-(M - 1)), N) { tmp.PB((i + M - 1) + S[1]); add_or(tmp); C++; } S[7] = C; FOR(i, K + 1, N + M - 1) { tmp.clear(); tmp.PB(S[0] + i); tmp.PB(S[5] + (i - (K + 1))); add_and(tmp); C++; } S[8] = C; FOR(i, (-(M - 1) + K + 1), N) { tmp.clear(); tmp.PB(S[1] + (M - 1 + i)); tmp.PB(S[6] + (M - 1 + i - (K + 1))); add_and(tmp); C++; } S[9] = C; tmp.clear(); FOR(i, S[7], S[9]) { tmp.PB(i); } if (!tmp.empty()) { add_or(tmp); C++; S[10] = C; //ok we nee S[4] to be good and S[9] to be bad. add_not(S[9]); tmp.clear(); tmp.PB(S[4]); tmp.PB(S[10]); add_and(tmp); } else { tmp.PB(S[4]); add_or(tmp); } //try to see if there's a violation 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...