#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 h, w, k, inst;
// bool add_or(vi& q) {
// cout << "or:\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 search()
{
int low = 0, high = w*h, mid;
while (high - low > 1) {
mid = (high + low) / 2;
vi ask(mid - low);
rep(i,low,mid) ask[i-low] = i;
inst++;
if (add_or(ask)) high = mid;
else low = mid;
}
return low;
}
void findk(int I)
{
int x = I % w, y = I / w;
// cout << "coords: " << x << ", "<<y<<endl;
int first_inst = inst + 1;
rep(dif, -k, k + 1) {
int X = x + dif;
if (X < 0 || X >= w) continue;
int ydif = k - abs(dif);
int Y = y + ydif;
if (Y >= 0 && Y < h) {
vi ask = {Y * w + X};
// cout << "coords: " << X << ", "<<Y<<endl;
add_or(ask);
inst++;
}
Y = y - ydif;
if (Y >= 0 && Y < h) {
vi ask = {Y * w + X};
// cout << "coords: " << X << ", "<<Y<<endl;
add_or(ask);
inst++;
}
}
// cout << first_inst << " , "<<inst << endl;
if (first_inst <= inst){
vi ask;
rep(i,first_inst, inst+1) ask.pb(i);
add_or(ask);
} else add_not(I);
}
void construct_network(int H, int W, int K)
{
h = H; w = W; k = K;
inst = w * h;
int x = search();
// cout << "X: " << x << endl;
findk(x);
}
// int main() {
// int H ,W, K; cin >> H>>W>>K;construct_network(H, W, K);
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
WA in grader: Invalid index |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
WA in grader: Invalid index |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
WA in grader: Invalid index |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
WA in grader: Invalid index |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
WA in grader: Invalid index |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
WA in grader: Invalid index |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
460 KB |
WA in grader: Invalid index |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
WA in grader: Invalid index |
2 |
Halted |
0 ms |
0 KB |
- |