#include "vision.h"
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
int n, m;
void construct_network(int H, int W, int K) {
n = H;
m = W;
int used_space = n*m-1;
// PARTE 1
vector<int> l_sum;
for(int sum = 0; sum <= n + m - 2; sum++) { // x + y
vector<int> q;
for(int x = 0; x < n; x++) {
int y = sum - x;
if(0 <= y and y < m) q.pb(x*m + y);
}
add_or(q); // adicionamos as somas
l_sum.pb(used_space + 1 + sum);
}
// n + m - 1 queries
add_or({used_space+1, used_space+2});
vector<int> pref_sum = {used_space + 1, used_space + n + m};
used_space += n + m;
for(int i = 2; i <= n + m - 2; i++) {
add_or({used_space, pref_sum[0] + i});
used_space++;
pref_sum.pb(used_space);
}
// PARTE 2
vector<int> l_dif;
for(int dif = 1 - m; dif <= n - 1; dif++) { // x - y
vector<int> q;
for(int x = 0; x < n; x++) {
int y = x - dif;
if(0 <= y and y < m) q.pb(x*m + y);
}
add_or(q); // adicionamos as diferencas
l_dif.pb(used_space + dif + m);
}
// n + m - 1 queries
add_or({used_space+1, used_space+2});
vector<int> pref_dif = {used_space+1, used_space+n+m};
used_space += n + m;
for(int i = 2; i <= n + m - 2; i++) {
add_or({used_space, pref_dif[0] + i});
used_space++;
pref_dif.pb(used_space);
}
// PARTE 3 - checar se há caras com distancia exatamente k
vector<int> q;
for(int i = K; i < n + m - 1; i++) {
add_and({l_sum[i], l_sum[i-K]});
used_space++;
q.pb(used_space);
}
for(int i = K; i < n + m - 1; i++) {
add_and({l_dif[i], l_dif[i-K]});
used_space++;
q.pb(used_space);
}
add_or(q);
used_space++;
int distK = used_space;
q.clear();
// PARTE 4 - checar se há caras com distância maior que K
for(int i = K+1; i < n + m - 1; i++) {
add_and({l_sum[i], pref_sum[i-K-1]});
used_space++;
q.pb(used_space);
}
for(int i = K+1; i < n + m - 1; i++) {
add_and({l_dif[i], pref_dif[i-K-1]});
used_space++;
q.pb(used_space);
}
add_or(q);
used_space++;
add_not(used_space);
used_space++;
int dist_max = used_space;
q.clear();
add_and({distK, dist_max});
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
WA in grader: Instruction with no inputs |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
WA in grader: Instruction with no inputs |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
WA in grader: Instruction with no inputs |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
WA in grader: Instruction with no inputs |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
WA in grader: Instruction with no inputs |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
WA in grader: Instruction with no inputs |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1368 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
432 KB |
Output is correct |
6 |
Correct |
1 ms |
388 KB |
Output is correct |
7 |
Correct |
4 ms |
860 KB |
Output is correct |
8 |
Correct |
3 ms |
860 KB |
Output is correct |
9 |
Correct |
6 ms |
1372 KB |
Output is correct |
10 |
Incorrect |
0 ms |
348 KB |
WA in grader: Instruction with no inputs |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
WA in grader: Instruction with no inputs |
3 |
Halted |
0 ms |
0 KB |
- |