#include "vision.h"
#include <vector>
#include <iostream>
using namespace std;
#define pb push_back
const int N = 500 + 10;
#define debug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
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++) {
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]);
if(n == 1) q.pb(row[0]);
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++) {
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]);
if(m == 1) q.pb(col[0]);
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);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
WA in grader: Instruction with no inputs |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
WA in grader: Instruction with no inputs |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
WA in grader: Instruction with no inputs |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
WA in grader: Instruction with no inputs |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
976 KB |
Output is correct |
2 |
Correct |
7 ms |
1060 KB |
Output is correct |
3 |
Correct |
8 ms |
976 KB |
Output is correct |
4 |
Correct |
7 ms |
976 KB |
Output is correct |
5 |
Incorrect |
2 ms |
1232 KB |
WA in grader: Instruction with no inputs |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
1872 KB |
WA in grader: Too many instructions |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
WA in grader: Instruction with no inputs |
4 |
Halted |
0 ms |
0 KB |
- |