the problem statement is:
[here] (CodeChef: Practical coding for everyone)
my code is this
Your code is not visible. Please post the code with proper formatting.
1 Like
#include <iostream>
#include<string>
#include<algorithm>
#include<climits>
using namespace std;
int main() {
int s=0,e=1000;
int mid;
int maxi=INT_MIN;
int y=0;
string inp;
while(s<=e)
{
mid= s+(e-s)/2;
cout<<"? "<<mid<<" "<<y<<endl;
fflush(stdout);
cin>>inp;
if(inp=="YES")
{maxi=max(mid,maxi);
s=mid+1;
}
else
e=mid-1;
}
int sqside=2*maxi;
int x=0;
s=0;
e=1000;
while(s<=e)
{
mid= s+(e-s)/2;
cout<<"? "<<x<<" "<<mid<<endl;
fflush(stdout);
cin>>inp;
if(inp=="YES")
{maxi=max(mid,maxi);
s=mid+1;
}
else
e=mid-1;
}
int triheight= maxi-sqside;
y=sqside;
s=0;
e=1000;
while(s<=e)
{
mid= s+(e-s)/2;
cout<<"? "<<mid<<" "<<y<<endl;
fflush(stdout);
cin>>inp;
if(inp=="YES")
{maxi=max(mid,maxi);
s=mid+1;
}
else
e=mid-1;
}
int tribase = 2*maxi;
int area1= sqside*sqside;
int area2= (tribase*triheight)/2;
int ans=area2+area1;
cout<<"! "<<ans<<endl;
fflush(stdout);
return 0;
}
this is my code
hey thanks for your help but i figured what was wrong 