QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#803317#9804. Guess the PolygonToboTL 1ms3860kbC++201.7kb2024-12-07 16:48:042024-12-07 16:48:04

Judging History

This is the latest submission verdict.

  • [2024-12-07 16:48:04]
  • Judged
  • Verdict: TL
  • Time: 1ms
  • Memory: 3860kb
  • [2024-12-07 16:48:04]
  • Submitted

answer

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<vector>
#include<bitset>
#include<random>
#include<ctime>
#include<queue>
#include<cmath>
#include<list>
#include<map>
#include<set>
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<long long,long long>
#define FF fflush(stdout)
#define inf 0x3f3f3f3f
#define endl "\n"
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
//char buf[1<<20],*p1,*p2;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
const int p=1e9+7;
inline ll read()
{
    ll s=0,f=1;
    char x=getchar();
    while(!isdigit(x))f=(x=='-'?-1:1),x=getchar();
    while(isdigit(x))s=(s*10+x-'0'+p)%p,x=getchar();
    return s*f;
}
ll ksm(int a,int b){ll ans=1,bs=a;while(b){if(b&1)ans=ans*bs%p;bs=bs*bs%p;b>>=1;}return ans;}
mt19937 rd(time(0));
#define reaD read
pii a[1005];
ll qy(int x)
{
    printf("? %d 1\n",x);
    FF;
    ll r=read(),s=read();
    return r*ksm(s,p-2)%p;
}
int main()
{
    int T=read();
    while(T--)
    {
        int n=read();
        for(int i=1;i<=n;i++)
        {
            int x=read(),y=read();
            a[i]=mp(x,y);
        }
        sort(a+1,a+n+1);
        ll las=0;
        ll ans=0;
        for(int i=2;i<n;i++)
        {
            ll len=qy(a[i].fi);
            ans=(ans+(las+len)*(a[i].fi-a[i-1].fi))%p;
            if(i==n-1)ans=(ans+len*(a[n].fi-a[i].fi))%p;
            las=len;
        }
        if(ans%2==0)printf("! %lld 1\n",ans>>1);
        else printf("! %lld 2\n",ans);
        FF;
    }
    return 0;
}

详细

Test #1:

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

input:

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

output:

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

result:

ok correct! (2 test cases)

Test #2:

score: -100
Time Limit Exceeded

input:

9
4
1 1
1 3
3 0
0 0
3 1
3 1

output:

? 1 1
? 1 1
! 9 2

result: