#include "vision.h"
#include <vector>
using namespace std;
#define pb push_back
const int N = 500 + 10;
int id[N][N], row[N], col[N], drow[N], dcol[N], not_dist_col[N], not_dist_row[N];
int dist_col[N], dist_row[N];
void construct_network(int n, int m, int k) {
int iter = -1;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
id[i][j] = ++iter;
}
}
for(int i = 0; i < n; i++) {
vector<int> q;
for(int j = 0; j < m; j++) q.pb(id[i][j]);
row[i] = ++iter;
add_or(q);
}
int d = max(n, m);
for(int i = 1; i <= d; i++) {
int cnt = 0;
int ii = 2, x = i;
while(x > 1) {
if(x % ii == 0) {
++cnt;
while(x % ii == 0) x /= ii;
}
++ii;
}
if(cnt > 1 || i >= n) continue;
vector<int> t;
for(int j = 0; j < i; j++) {
if(j + i >= n) break;
vector<int> q;
for(int x = j; x < n; x += i) q.pb(row[x]);
t.pb(++iter);
add_xor(q);
}
++iter;
add_or(t);
drow[i] = ++iter;
add_not(iter - 1);
}
for(int i = n - 1; i >= 0; i--) {
int x = i;
vector<int> q;
int ii = 2;
if(i) q.pb(drow[1]);
while(x > 1) {
int curr = 1;
if(x % ii == 0) {
while(x % ii == 0) x /= ii, curr *= ii;
}
q.pb(drow[curr]);
++ii;
}
for(int j = i + 1; j < n; j++) q.pb(not_dist_row[j]);
dist_row[i] = ++iter;
add_and(q);
not_dist_row[i] = ++iter;
add_not(iter - 1);
}
for(int i = 0; i < m; i++) {
vector<int> q;
for(int j = 0; j < n; j++) q.pb(id[j][i]);
col[i] = ++iter;
add_or(q);
}
for(int i = 1; i <= d; i++) {
int cnt = 0;
int ii = 2, x = i;
while(x > 1) {
if(x % ii == 0) {
++cnt;
while(x % ii == 0) x /= ii;
}
++ii;
}
if(cnt > 1 || i >= m) continue;
vector<int> t;
for(int j = 0; j < i; j++) {
if(j + i >= m) break;
vector<int> q;
for(int x = j; x < m; x += i) q.pb(col[x]);
t.pb(++iter);
add_xor(q);
}
++iter;
add_or(t);
dcol[i] = ++iter;
add_not(iter - 1);
}
for(int i = m - 1; i >= 0; i--) {
int x = i;
vector<int> q;
int ii = 2;
if(i) q.pb(dcol[1]);
while(x > 1) {
int curr = 1;
if(x % ii == 0) {
while(x % ii == 0) x /= ii, curr *= ii;
}
q.pb(dcol[curr]);
++ii;
}
for(int j = i + 1; j < m; j++) q.pb(not_dist_col[j]);
dist_col[i] = ++iter;
add_and(q);
not_dist_col[i] = ++iter;
add_not(iter - 1);
}
vector<int> q;
for(int i = 0; i < k; i++) {
if(i > n - 1) break;
if(k - i > m - 1) continue;
++iter;
add_and({dist_row[i], dist_col[k - i]});
q.pb(iter);
}
add_or(q);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
on inputs (0, 0), (1, 0), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
2560 KB |
on inputs (80, 199), (81, 199), expected 1, but computed 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
WA in grader: Instruction with no inputs |
2 |
Halted |
0 ms |
0 KB |
- |