#include <bits/stdc++.h>
#include <iostream>
#include "vision.h"
using namespace std;
#define rep(i,a,b) for(int i = a; i < b; i++)
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int w, h, k, n_instructions;
// bool add_or(vi& q) {
// cout << "or:\n";
// for(auto &i : q) cout << i << " ";cout<<endl;
// bool ans; cin >> ans;
// return ans;
// }
//
// bool add_and(vi& q) {
// cout << "and:\n";
// for(auto &i : q) cout << i << " ";cout<<endl;
// bool ans; cin >> ans;
// return ans;
// }
//
// bool add_not(int x ) {
// cout << "not:\n";
// cout << x << endl;
// bool ans; cin >> ans; return ans;
// }
int binary_search() {
vi p(w*h); rep(i,0,w*h) p[i] = i;
int psz = p.size();
while (psz > 1) {
vi half(psz / 2);
rep(i,0,psz / 2) half[i] = p[i];
n_instructions++;
vi np;
if (add_or(half)) np = half;
else {
rep(i, psz / 2, psz) np.pb(p[i]);
}
p = np;
psz = p.size();
}
return p[0];
}
void get_k(int x) {
int wx = x % w, hx = x / w;
int first_inst = n_instructions;
rep(add_w, -k, k + 1) {
int nw = wx + add_w,
nh1 = hx + k - abs(add_w),
nh2 = hx - (k - abs(add_w));
if (!(0 <= nw && nw < w)) continue;
if (0 <= nh1 && nh1 < h) {
int ask = nh1 * w + nw;
vi k = {ask};
add_and(k);
n_instructions++;
}
if (0 <= nh2 && nh2 < h) {
int ask = nh2 * w + nw;
vi k = {ask};
add_and(k);
n_instructions++;
}
}
if (first_inst != n_instructions) {
vi f;
rep(i, first_inst, n_instructions) f.pb(i);
add_or(f);
}
else {
add_not(x);
}
}
void construct_network(int H, int W, int K) {
h = H; w = W; k = K;
n_instructions = w*h;
int x = binary_search();
get_k(x);
return;
}
//
// int main() {
// construct_network(3, 3, 1);
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
on inputs (0, 1), (0, 2), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
on inputs (0, 1), (0, 2), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
on inputs (0, 1), (0, 2), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
on inputs (0, 1), (0, 2), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
on inputs (0, 1), (0, 3), expected 0, but computed 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
2 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
4 ms |
460 KB |
Output is correct |
21 |
Correct |
4 ms |
460 KB |
Output is correct |
22 |
Correct |
4 ms |
460 KB |
Output is correct |
23 |
Correct |
4 ms |
460 KB |
Output is correct |
24 |
Correct |
3 ms |
460 KB |
Output is correct |
25 |
Correct |
3 ms |
460 KB |
Output is correct |
26 |
Correct |
4 ms |
460 KB |
Output is correct |
27 |
Correct |
5 ms |
684 KB |
Output is correct |
28 |
Correct |
6 ms |
684 KB |
Output is correct |
29 |
Correct |
5 ms |
684 KB |
Output is correct |
30 |
Correct |
5 ms |
736 KB |
Output is correct |
31 |
Correct |
8 ms |
684 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
684 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 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
on inputs (0, 1), (0, 2), expected 0, but computed 1 |
3 |
Halted |
0 ms |
0 KB |
- |