Bear and Houses queries QHOUSE

Please anyone find out bug in this submission
https://www.codechef.com/viewsolution/32461563

Did you even test your program before submitting it?

line 65, probably a typo: `triangle_base + triangle_height / 2;`

Oh sorry! that was very silly mistake, also i mistaken in printing ! in the last line. Really felt bad about it.

And i donâ€™t know how to test interactive problems, apart from checking logic

Try this

Checker
``````// Author: shubh_singh
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <chrono>
#include <complex>
#define endl "\n"
#define Debugbuild
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c), x) != c.end())
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define f first
#define s second
#define desc greater<int>()
using namespace std;
#ifdef Debugbuild
struct Judge{
Judge(){
srand(time(0));
x = rand()%20 + 1;
square=2*(rand()%10 + 1);
y=square + rand()%10 + 1;
queries=0;
area = square*square + x*(y-square);
}
cout<<X<<" "<<Y<<"\n";
++queries;
if(queries>100){
assert(0);
}
bool ans;
if(Y<square){
ans= abs(X)<=square/2;
}
else if(Y>square){
ans= isInside(-x, square, x, square, 0, y, X, Y);
}
else{
ans= abs(X)<=max(x, square);
}
cout<<ans<<"\n";
return ans;
}
void check(int ans){
assert(ans==area);
}
private :
int x,y,square;
int queries;
int area;
int getarea(int x1, int y1, int x2, int y2, int x3, int y3){
return abs((x1*(y2-y3) + x2*(y3-y1)+ x3*(y1-y2)));
}
bool isInside(int x1, int y1, int x2, int y2, int x3, int y3, int x, int y) {
int A = getarea(x1, y1, x2, y2, x3, y3);
int A1 = getarea (x, y, x2, y2, x3, y3);
int A2 = getarea (x1, y1, x, y, x3, y3);
int A3 = getarea (x1, y1, x2, y2, x, y);
return (A == A1 + A2 + A3);
}
};
Judge judge;
#endif
bool ask(int x, int y) {
printf("? %d %d\n", x, y);
fflush(stdout);
string response;
cin >> response;
return response[0] == 'Y';
}
#ifdef Debugbuild
int findX(int y) {
int x_low = 0, x_high = 1000;
while (x_low < x_high) {
int x_mid = (x_low + x_high + 1) / 2;
x_low = x_mid;
else
x_high = x_mid - 1;
}
return x_low;
}

int findY(int x) {
int y_low = 0, y_high = 1000;
while (y_low < y_high) {
int y_mid = (y_low + y_high + 1) / 2;
y_low = y_mid;
else
y_high = y_mid - 1;
}
return y_low;
}
#else
int findX(int y) {
int x_low = 0, x_high = 1000;
while (x_low < x_high) {
int x_mid = (x_low + x_high + 1) / 2;
x_low = x_mid;
else
x_high = x_mid - 1;
}
return x_low;
}

int findY(int x) {
int y_low = 0, y_high = 1000;
while (y_low < y_high) {
int y_mid = (y_low + y_high + 1) / 2;
y_low = y_mid;
else
y_high = y_mid - 1;
}
return y_low;
}
#endif
int main() {
int square_side = findX(0) * 2;
int triangle_base = findX(square_side) * 2;
int triangle_height = findY(0) - square_side;
int area = square_side * square_side + triangle_base * triangle_height / 2;
#ifdef Debugbuild
judge.check(area);
#else
printf("! %d\n", area);
#endif
return 0;
}
``````