QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#850903#9804. Guess the Polygonwangzhifang#WA 3ms7892kbC++142.5kb2025-01-10 12:53:002025-01-10 12:53:01

Judging History

This is the latest submission verdict.

  • [2025-01-10 12:53:01]
  • Judged
  • Verdict: WA
  • Time: 3ms
  • Memory: 7892kb
  • [2025-01-10 12:53:00]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
typedef __int128 ll;
constexpr int max_n=1000000;
typedef pair<int,int> pii;
pii p[max_n+1];
struct frc{
	ll a,b;
	void read(){
		long long x,y;
		scanf("%lld%lld",&x,&y);
		a=x,b=y;
	}
	void writeln(){
		printf("%lld %lld\n",(long long)(a),(long long)(b));
	}
	void simpl(){
		ll g=__gcd(a,b);
		a/=g,b/=g;
	}
	friend frc operator +(const frc&x,const frc&y){
		ll g=__gcd(x.b,y.b);
		frc res;
		res.b=x.b/g*y.b;
		res.a=x.a*(y.b/g)+y.a*(x.b/g);
		res.simpl();
		return res;
	}
	friend frc operator -(const frc&x,const frc&y){
//		fprintf(stderr,"^^ - %lld %lld  %lld %lld\n",x.a,x.b,y.a,y.b);
		ll g=__gcd(x.b,y.b);
//		fprintf(stderr,"%lld,\n",g);
		frc res;
		res.b=x.b/g*y.b;
		res.a=x.a*(y.b/g)-y.a*(x.b/g);
		res.simpl();
//		fprintf(stderr,"^^ - done\n");
		return res;
	}
	friend frc operator /(frc x,const ll y){
//		fprintf(stderr,"^^ / %lld\n",y);
		ll g=__gcd(x.a,y);
		x.a/=g,x.b*=y/g;
		return x;
	}
	friend frc operator *(frc x,const ll y){
		if(y==0){
			x.b=1,x.a=0;
			return x;
		}
		ll g=__gcd(x.b,y);
		x.b/=g,x.a*=y/g;
		return x;
	}
};
frc a[max_n+1];
bool err[max_n+1];
void test(){
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; ++i)
		scanf("%d%d",&p[i].first,&p[i].second);
	sort(p+1,p+n+1);
	for(int i=2; i<n; ++i)
		if(p[i].first==p[i-1].first)
			if(p[i].first<1000)
				printf("? %d 3\n",p[i].first*3+1),err[i]=0;
			else
				err[i]=1;
		else
			if(p[i].first==p[i+1].first)
				if(p[i].first>0)
					printf("? %d 3\n",p[i].first*3-1),err[i]=0;
				else
					err[i]=1;
			else
				printf("? %d 1\n",p[i].first),err[i]=0;
	fflush(stdout);
	err[1]=err[n]=1;
	for(int i=1; i<=n; ++i)
		if(err[i])
			a[i].a=0,a[i].b=1;
		else
			a[i].read();
	for(int i=2; i<n; ++i)
		if(p[i].first==p[i-1].first){
//			fprintf(stderr,"x %d\n",i);
			if(p[i].first==p[i+1].first)
				continue;
			if(i+1<n&&p[i+1].first==p[i+2].first)
				a[i]=a[i]-(a[i+1]-a[i])/((p[i+1].first-p[i].first)*3-2);
			else
				a[i]=a[i]-(a[i+1]-a[i])/((p[i+1].first-p[i].first)*3-1);
		}
		else
			if(p[i].first==p[i+1].first)
//			fprintf(stderr,"u %d\n",i),
				a[i]=a[i]+(a[i]-a[i-1])/((p[i].first-p[i-1].first)*3-1);
//	for(int i=2; i<n; ++i)
//		fprintf(stderr,"%lld %lld\n",a[i].a,a[i].b);
	frc ans;
	ans.a=0,ans.b=1;
	for(int i=1; i<n; ++i)
		ans=ans+(a[i]+a[i+1])*(p[i+1].first-p[i].first)/2;
	printf("! ");
	ans.writeln();
	fflush(stdout);
}
int main(){
	int t;
	scanf("%d",&t);
	for(; t; test(),--t);
	return 0;
}

詳細信息

Test #1:

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

input:

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

output:

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

result:

ok correct! (2 test cases)

Test #2:

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

input:

9
4
1 1
1 3
3 0
0 0
2 1
5 6
4
0 0
1 3
1 1
3 0
2 3
5 2
4
0 0
3 0
1 2
1 1
2 3
5 6
4
0 0
3 0
1 2
1 1
4 3
5 6
4
0 0
3 0
1 1
1 2
2 3
5 3
3
1000 0
0 0
0 1000
2999 3
4
0 0
1000 0
1000 1000
0 1000
1000 1
1000 1
5
0 1
1000 1000
1000 0
0 1000
1 0
2998 3
1000 1
1000 1
9
4 1000
3 1
2 1000
3 1000
1 1
2 1
0 0
1 1...

output:

? 2 3
? 4 3
! 5 2
? 2 3
? 4 3
! 7 2
? 2 3
? 4 3
! 3 2
? 2 3
? 4 3
! 2 1
? 2 3
? 4 3
! 5 2
? 1 3
! 500000 1
? 1 3
? 2999 3
! 1000000 1
? 1 3
? 1 1
? 2999 3
! 1999999 2
? 2 3
? 4 3
? 5 3
? 7 3
? 8 3
? 10 3
? 11 3
! 4003 2

result:

ok correct! (9 test cases)

Test #3:

score: 0
Accepted
time: 0ms
memory: 5856kb

input:

78
8
951 614
927 614
957 614
957 604
937 614
942 619
951 610
927 604
10 1
10 1
15 1
19 3
10 1
10 1
7
562 260
602 250
582 255
587 260
602 260
562 250
577 260
10 1
10 1
5 1
10 1
10 1
3
454 98
494 68
455 68
117 4
3
526 589
566 559
527 559
117 4
3
854 496
854 466
894 466
119 4
3
797 264
827 254
857 264
...

output:

? 2782 3
? 937 1
? 942 1
? 2852 3
? 2854 3
? 2870 3
! 317 1
? 1687 3
? 577 1
? 582 1
? 587 1
? 1805 3
! 375 1
? 455 1
! 585 1
? 527 1
! 585 1
? 2563 3
! 600 1
? 827 1
! 300 1
? 2158 3
! 600 1
? 162 1
! 400 1
? 2227 3
? 2240 3
? 2242 3
? 2255 3
? 2257 3
? 2375 3
! 275 1
? 2797 3
? 2810 3
? 2812 3
? 2...

result:

ok correct! (78 test cases)

Test #4:

score: -100
Wrong Answer
time: 3ms
memory: 7892kb

input:

34
24
123 815
168 800
133 795
27 827
153 805
28 830
178 780
138 810
78 830
192 772
148 790
88 810
43 825
183 795
103 805
163 785
118 800
93 825
63 835
73 815
58 820
198 790
48 840
108 820
10 3
95 6
15 2
95 6
15 2
95 6
15 2
95 6
15 2
95 6
15 2
95 6
15 2
95 6
15 2
95 6
15 2
95 6
15 2
95 6
15 2
15 1
24...

output:

? 28 1
? 43 1
? 48 1
? 58 1
? 63 1
? 73 1
? 78 1
? 88 1
? 93 1
? 103 1
? 108 1
? 118 1
? 123 1
? 133 1
? 138 1
? 148 1
? 153 1
? 163 1
? 168 1
? 178 1
? 183 1
? 192 1
! 1925 1
? 54 1
? 69 1
? 74 1
? 84 1
? 89 1
? 99 1
? 104 1
? 114 1
? 119 1
? 129 1
? 134 1
? 144 1
? 149 1
? 159 1
? 164 1
? 174 1
? ...

result:

wrong answer format  Expected int32, but "-6696783101603801891" found (test case 27)