QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#822029#9804. Guess the Polygonwwww22WA 0ms5724kbC++201.7kb2024-12-19 20:44:512024-12-19 20:44:55

Judging History

This is the latest submission verdict.

  • [2024-12-19 20:44:55]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 5724kb
  • [2024-12-19 20:44:51]
  • Submitted

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;
ll w;
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";
//	}
	w=llround(ans);
	cout<<"! "<<(w&1?w:w>>1)<<' '<<1+(w&1)<<endl;
	return;
	
	SEC:
		int f=0;
		fo(i,2,n)
		{
			if(i==n)
			{
				an[i]=an[i-1]/2;
				break;
			}
			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<<an[i]<<" "<<ans<<"\n";
		}
		w=llround(ans);
		cout<<"! "<<(w&1?w:w>>1)<<' '<<1+(w&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: 0ms
memory: 5724kb

input:

2
4
3 0
1 3
1 1
0 0
1 1

output:

? 1 2
! 2 1

result:

wrong answer the answer is incorrect, expect: 3/1, find: 2/1 (test case 1)