#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_or(colXor);
int OrAllColsXor = id++;
vector <int> rowsAnd(h-1);
for(int i=1; i<h; i++){
add_and({rowOr[i-1] ,rowOr[i]});
rowsAnd[i] = id++;
}
vector <int> colsAnd(h-1);
for(int i=1; i<w; i++){
add_and({colOr[i-1] ,colOr[i]});
colsAnd[i] = id++;
}
//(!OrAllColsXor && OrAllRowsAnd) || (!OrAllRowsXor && OrAllColsAnd)
add_or(rowsAnd);
int OrAllRowsAnd = id++;
add_or(colsAnd);
int OrAllColsAnd = id++;
add_not(OrAllRowsXor);
int notOrAllRowsXor = id++;
add_not(OrAllColsXor);
int notOrAllColsXor = id++;
add_and({OrAllRowsAnd ,notOrAllColsXor}) ,id++;
add_and({OrAllColsAnd ,notOrAllRowsXor}) ,id++;
add_or({id-2 ,id-1});
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Incorrect |
4 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 |
22 ms |
2040 KB |
Output is correct |
2 |
Incorrect |
5 ms |
256 KB |
on inputs (0, 1), (1, 1), expected 1, but computed 0 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |