QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#821992 | #9804. Guess the Polygon | wwww22 | WA | 1ms | 5744kb | C++20 | 1.7kb | 2024-12-19 20:19:09 | 2024-12-19 20:19:11 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define db long double
#define eb emplace_back
#define pi pair<ll,ll>
#define mk make_pair
#define fo(i,a,b) for(ll (i)=(a);(i)<=(b);(i)++)
#define fd(i,a,b) for(ll (i)=(a);(i)>=(b);(i)--)
using namespace std;
const int N=5e5+10;
int n;
struct node
{
int x,y;
}a[N];
bool cmp(node a,node b)
{
if(a.x!=b.x)
{
return a.x<b.x;
}
else
{
return a.y<b.y;
}
}
db p,q;
db ask(int x)
{
cout<<"? "<<x<<" "<<1<<endl;
cin>>p>>q;
return p/q;
}
db an[N];
db ans;
ll aaa;
void solve(){
cin>>n;
ans=0;
an[1]=0;
an[n]=0;
fo(i,1,n)
{
cin>>a[i].x>>a[i].y;
}
sort(a+1,a+1+n,cmp);
fo(i,2,n)
{
if(a[i].x==a[i-1].x)
{
goto SEC;
}
}
fo(i,2,n-1)
{
an[i]=ask(a[i].x);
}
fo(i,2,n)
{
ans+=(a[i].x-a[i-1].x)*(an[i]+an[i-1]);
// cout<<ans<<"\n";
}
// fo(i,1,n)
// {
// cout<<a[i].x<<" "<<a[i].y<<"\n";
// }
aaa=(ll)(ans+0.5);
if(aaa%2)
{
cout<<"! "<<aaa<<" "<<2<<endl;
}
else
{
cout<<"! "<<aaa/2<<" "<<1<<endl;
}
return;
SEC:
fo(i,2,n-1)
{
if(i>2&&(a[i].x==a[i-1].x))
{
an[i]=an[i-1];
continue;
}
else
{
int tmp=a[i].x+a[i-1].x;
if(tmp%2)
{
cout<<"? "<<tmp<<" "<<2<<endl;
cin>>p>>q;
an[i]=p/q;
}
else
{
an[i]=ask(tmp/2);
}
}
}
fo(i,2,n)
{
ans+=(a[i].x-a[i-1].x)*(an[i])*2;
// cout<<ans<<"\n";
}
aaa=(ll)(ans+0.5);
if(aaa%2)
{
cout<<"! "<<aaa<<" "<<2<<endl;
}
else
{
cout<<"! "<<aaa/2<<" "<<1<<endl;
}
}
int main(){
// ios::sync_with_stdio(false);
// cin.tie(0),cout.tie(0);
int T=1;
cin>>T;
while(T--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5744kb
input:
2 4 3 0 1 3 1 1 0 0 1 1
output:
? 1 2 ! 1 1
result:
wrong answer the answer is incorrect, expect: 3/1, find: 1/1 (test case 1)