This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dis(int x, int y, int a, int b) {
return abs(x-a)+abs(y-b);
}
int w;
int num(int x, int y) {
return x*w+y;
}
int locknum[2], row, col;
pair<int, int> calc(pair<int, int> prv, int curr) {
vector<int> v;
v={curr, prv.first};
pair<int, int> on={add_and(v), 0};
on.second=on.first;
for(int i=prv.first+1; i<=min(prv.second, prv.first+8); i++) {
v={on.second, i};
on.second=add_and(v);
}
v={prv.first, curr};
pair<int, int> res={add_xor(v), 0};
res.second=res.first;
for(int i=prv.first+1, j=on.first; j<=on.second; i++, j++) {
if(i>prv.second) v={locknum[0], j};
else v={i, j};
res.second=add_xor(v);
}
return res;
}
void construct_network(int n, int m, int k) {
vector<int> v;
w=m;
for(int i=0; i<n; i++) for(int j=0; j<m; j++) v.push_back(num(i, j));
locknum[1]=add_or(v);
locknum[0]=add_not(locknum[1]);
v.clear();
int s=locknum[0]+1, e=locknum[0]+1;
for(int i=0; i<n; i++) {
for(int j=0; j<m; j++) v.push_back(num(i, j));
e=add_or(v);
v.clear();
}
for(int i=s; i<=e; i++) v.push_back(i);
int state=add_xor(v);
state=add_not(state);
v={locknum[0], s};
row=add_xor(v);
v.clear();
for(int i=s+1; i<=e; i++) {
v={row+i-s-1, i};
add_xor(v);
}
for(int i=0; i<n; i++) {
v={row+i, state};
add_and(v);
}
v.clear();
row+=n;
s=row+n;
for(int i=0; i<m; i++) {
for(int j=0; j<n; j++) v.push_back(num(j, i));
e=add_or(v);
v.clear();
}
for(int i=s; i<=e; i++) v.push_back(i);
state=add_xor(v);
state=add_not(state);
v={locknum[0], s};
col=add_xor(v);
for(int i=s+1; i<=e; i++) {
v={col+i-s-1, i};
add_xor(v);
}
for(int i=0; i<m; i++) {
v={col+i, state};
add_and(v);
}
col+=m;
v.clear();
for(int i=0; i<n; i++) v.push_back(row+i);
for(int i=0; i<m; i++) v.push_back(col+i);
pair<int, int> res={locknum[0], locknum[0]};
for(auto i: v) res=calc(res, i);
v={locknum[0]};
while(res.second<res.first+9) res.second=add_and(v);
pair<int, int> digit={res.second+1, res.second+1};
for(int i=0; i<10; i++) {
v={locknum[!!(k&1<<i)], res.first+i};
digit.second=add_xor(v);
}
v.clear();
for(int i=digit.first; i<=digit.second; i++) v.push_back(i);
int ans=add_or(v);
add_not(ans);
}
# | 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... |