QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#821989#9804. Guess the Polygonwwww22WA 1ms5852kbC++201.7kb2024-12-19 20:17:202024-12-19 20:17:21

Judging History

This is the latest submission verdict.

  • [2024-12-19 20:17:21]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 5852kb
  • [2024-12-19 20:17:20]
  • 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;
void solve(){
	cin>>n;
	ans=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;
		}
	}
	an[1]=0;
	an[n]=0;
	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)
		{
			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();
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5852kb

input:

2
4
3 0
1 3
1 1
0 0
1 1
1 1
3
0 0
999 1000
1000 999
1999 1000

output:

? 1 2
? 2 1
! 3 1
? 999 1
! 1999 2

result:

ok correct! (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 5792kb

input:

9
4
1 1
1 3
3 0
0 0
3 2
1 2
4
0 0
1 3
1 1
3 0
1 2
3 2
4
0 0
3 0
1 2
1 1
1 2
1 2
4
0 0
3 0
1 2
1 1
1 1
1 2
4
0 0
3 0
1 1
1 2
1 2
1 1
3
1000 0
0 0
0 1000
1000 1

output:

? 1 2
? 2 1
! 5 2
? 1 2
? 2 1
! 7 2
? 1 2
? 2 1
! 3 2
? 1 2
? 2 1
! 2 1
? 1 2
? 2 1
! 5 2
? 0 1
? 500 1

result:

wrong answer number of queries exceeds the limit: 1 (test case 6)