#include <bits/stdc++.h>
#include "vision.h"
//#include "grader.cpp"
using namespace std;
int h ,w ,k;
int d(int i ,int j){ return i*w+j; }
int dist(int r ,int c ,int i ,int j){
return abs(r-i) + abs(j-c);
}
void construct_network(int H, int W, int K) { h=H ,w=W ,k=K;
int id = h*w;
vector <int> rowOr(h) ,rowXor(h);
for(int i=0; i<h; i++){
vector <int> r;
for(int j=0; j<w; j++)
r.push_back(d(i ,j));
add_or(r);
rowOr[i] = id++;
add_xor(r);
rowXor[i] = id++;
}
vector <int> colOr(w) ,colXor(w);
for(int j=0; j<w; j++){
vector <int> c;
for(int i=0; i<h; i++)
c.push_back(d(i ,j));
add_or(c);
colOr[j] = id++;
add_xor(c);
colXor[j] = id++;
}
add_or(rowXor);
int OrAllRowsXor = id++;
add_not(OrAllRowsXor);
int notOrAllRowsXor = id++;
add_or(colXor);
int OrAllColsXor = id++;
add_not(OrAllColsXor);
int notOrAllColsXor = id++;
vector <int> rowsAnd(h-1);
for(int i=1; i<h; i++){
add_and({rowOr[i-1] ,rowOr[i]});
rowsAnd[i-1] = id++;
}
vector <int> colsAnd(w-1);
for(int i=1; i<w; i++){
add_and({colOr[i-1] ,colOr[i]});
colsAnd[i-1] = id++;
}
//(!OrAllColsXor && OrAllRowsAnd) || (!OrAllRowsXor && OrAllColsAnd)
if(h>1 && w>1){
add_or(rowsAnd);
int OrAllRowsAnd = id++;
add_or(colsAnd);
int OrAllColsAnd = id++;
add_and({OrAllRowsAnd ,notOrAllColsXor}) ,id++;
add_and({OrAllColsAnd ,notOrAllRowsXor}) ,id++;
add_or({id-2 ,id-1});
}
else if(h == 1){
add_or(colsAnd);
}
else if(w == 1){
add_or(rowsAnd);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Incorrect |
5 ms |
256 KB |
on inputs (0, 0), (0, 1), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Incorrect |
5 ms |
256 KB |
on inputs (0, 0), (0, 1), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Incorrect |
5 ms |
256 KB |
on inputs (0, 0), (0, 1), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Incorrect |
5 ms |
256 KB |
on inputs (0, 0), (0, 1), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
5 ms |
384 KB |
on inputs (0, 0), (0, 1), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
5 ms |
384 KB |
on inputs (0, 0), (0, 1), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
1920 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
8 ms |
640 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
14 ms |
1152 KB |
Output is correct |
8 |
Correct |
14 ms |
1152 KB |
Output is correct |
9 |
Correct |
24 ms |
1920 KB |
Output is correct |
10 |
Correct |
5 ms |
256 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Incorrect |
5 ms |
256 KB |
on inputs (0, 0), (0, 1), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |