제출 #1161098

#제출 시각아이디문제언어결과실행 시간메모리
1161098browntoadVision Program (IOI19_vision)C++20
100 / 100
19 ms3144 KiB
#include <bits/stdc++.h> #include "vision.h" // #include "grader.cpp" using namespace std; #define ll long long // #define int ll #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) for (int i = (n)-1; i >= 0; i--) #define RREP1(i, n) for (int i = (n); i >= 1; i--) #define REP1(i, n) FOR(i, 1, n+1) #define pii pair<int, int> #define ppi pair<pii, int> #define pip pair<int, pii> #define f first #define s second #define pb push_back #define ALL(x) (x).begin(), (x).end() #define SZ(x) (int)((x).size()) #define endl '\n' #define IOS() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) const ll maxn = 205; const ll inf = 1e9; const ll mod = 998244353; ll pw(ll x, ll p, ll m){ ll ret = 1; while(p > 0){ if (p & 1){ ret *= x; ret %= m; } x *= x; x %= m; p >>= 1; } return ret; } ll inv(ll x, ll m){ return pw(x, m-2, m); } int col[maxn][maxn]; int ord[maxn][maxn]; int n, m; bool ok(int a, int b){ return (a >= 0 && b >= 0 && a < n && b < m); } void run(int a, int b){ } void construct_network(int H, int W, int k) { n = H; m = W; /*std::vector<int> Ns; 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); */ /*REP(i, H){ REP(j, W){ FOR(a, i, H){ REP(b, W){ if (abs(a-i) + abs(b-j) == K){ pos.pb({i*W+j, a*W+b}); } } } } } */ vector<int> pos; if (n-1 > k){ vector<int> xr; REP(i, n){ vector<int> tmp; REP(j, m){ tmp.pb(i*W + j); } xr.pb(add_xor(tmp)); } vector<int> vc, pf, sf, fina; REP(i, n){ if (i+k-1 >= n) break; vector<int> tmp; FOR(j, i, i+k) tmp.pb(xr[j]); vc.pb(add_or(tmp)); } vector<int> cur; REP(i, SZ(vc)){ cur.pb(vc[i]); pf.pb(add_or(cur)); } cur.clear(); RREP(i, SZ(vc)){ cur.pb(vc[i]); sf.pb(add_or(cur)); } reverse(ALL(sf)); REP(i, SZ(vc)){ int tmp = add_not(vc[i]); fina.pb(add_and({pf[i], sf[i], tmp})); } int res = add_or(fina); res = add_not(res); pos.pb(res); } if (m-1 > k){ vector<int> xr; REP(j, m){ vector<int> tmp; REP(i, n){ tmp.pb(i*W + j); } xr.pb(add_xor(tmp)); } vector<int> vc, pf, sf, fina; REP(j, m){ if (j+k-1 >= m) break; vector<int> tmp; FOR(i, j, j+k) tmp.pb(xr[i]); vc.pb(add_or(tmp)); } vector<int> cur; REP(i, SZ(vc)){ cur.pb(vc[i]); pf.pb(add_or(cur)); } cur.clear(); RREP(i, SZ(vc)){ cur.pb(vc[i]); sf.pb(add_or(cur)); } reverse(ALL(sf)); REP(i, SZ(vc)){ int tmp = add_not(vc[i]); fina.pb(add_and({pf[i], sf[i], tmp})); } int res = add_or(fina); res = add_not(res); pos.pb(res); } // dis x+y = k { map<int, vector<int>> mp; REP(i, n){ REP(j, m){ if (!mp.count(i+j)){ mp[i+j] = {i*W + j}; } else mp[i+j].pb(i*W + j); } } vector<int> xr, adid; for (auto [v, vv]:mp){ xr.pb(add_xor(vv)); } REP(i, SZ(xr)){ if (i+k >= SZ(xr)) break; adid.pb(add_and({xr[i], xr[i+k]})); } pos.pb(add_or(adid)); } { map<int, vector<int>> mp; REP(i, n){ REP(j, m){ if (!mp.count(i-j)){ mp[i-j] = {i*W + j}; } else mp[i-j].pb(i*W + j); } } vector<int> xr, adid; for (auto [v, vv]:mp){ xr.pb(add_xor(vv)); } REP(i, SZ(xr)){ if (i+k >= SZ(xr)) break; adid.pb(add_and({xr[i], xr[i+k]})); } pos.pb(add_or(adid)); } pos[SZ(pos)-2] = add_or({pos[SZ(pos)-2], pos[SZ(pos)-1]}); pos.pop_back(); add_and(pos); 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...