#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;
REP(a, K+1){
int b = K-a;
if (a > n-1 || b > m-1) continue;
// case 1: +b
vector<int> tmp;
int curcol = 0;
vector<vector<int>> cols, ords;
vector<int> colstorage, ordstorage;
REP(i, n){
REP(j, m){
if (!ok(i-a, j-b)){
col[i][j] = curcol++;
ord[i][j] = 0;
}
else{
col[i][j] = col[i-a][j-b];
ord[i][j] = ord[i-a][j-b]+1;
}
if (SZ(cols) <= col[i][j]) cols.pb({});
cols[col[i][j]].pb(i*W+j);
if (SZ(ords) <= ord[i][j]) ords.pb({});
ords[ord[i][j]].pb(i*W+j);
}
}
for (auto vv:cols){
if (SZ(vv) == 1) continue;
colstorage.pb(add_xor(vv));
}
int p1 = add_or(colstorage);
p1 = add_not(p1);
for (auto vv:ords){
ordstorage.pb(add_xor(vv));
}
vector<int> chastorage;
REP(i, SZ(ordstorage)-1){
chastorage.pb(add_and({ordstorage[i], ordstorage[i+1]}));
}
int p2 = add_or(chastorage);
pos.pb(add_and({p1, p2}));
if (a != 0 && b != 0){ // case 2: -b
b = -b;
vector<int> tmp;
int curcol = 0;
vector<vector<int>> cols, ords;
vector<int> colstorage, ordstorage;
REP(i, n){
RREP(j, m){
if (!ok(i-a, j-b)){
col[i][j] = curcol++;
ord[i][j] = 0;
}
else{
col[i][j] = col[i-a][j-b];
ord[i][j] = ord[i-a][j-b]+1;
}
if (SZ(cols) <= col[i][j]) cols.pb({});
cols[col[i][j]].pb(i*W+j);
if (SZ(ords) <= ord[i][j]) ords.pb({});
ords[ord[i][j]].pb(i*W+j);
}
}
for (auto vv:cols){
if (SZ(vv) == 1) continue;
colstorage.pb(add_xor(vv));
}
int p1 = add_or(colstorage);
p1 = add_not(p1);
for (auto vv:ords){
ordstorage.pb(add_xor(vv));
}
vector<int> chastorage;
REP(i, SZ(ordstorage)-1){
chastorage.pb(add_and({ordstorage[i], ordstorage[i+1]}));
}
int p2 = add_or(chastorage);
pos.pb(add_and({p1, p2}));
}
}
add_or(pos);
return;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |