QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#69721#2350. Integer CowHeinzTL 1106ms3716kbC++141.7kb2022-12-30 17:55:182022-12-30 17:55:20

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-30 17:55:20]
  • 评测
  • 测评结果:TL
  • 用时:1106ms
  • 内存:3716kb
  • [2022-12-30 17:55:18]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
double X0,Y0,x,y,r;
double Dis(double x1,double y1,double x2, double y2)
{
//	printf("%lf %lf %lf %lf\n",x1,y1,x2,y2);
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int main()
{
	int T;
	scanf("%d",&T);
	while(T--)
	{
		scanf("%lf%lf%lf%lf%lf",&x,&y,&r,&X0,&Y0);
//		puts("!!!");
		double D=Dis(x,y,X0,Y0);
//		printf("D:%lf r:%lf\n",D,r);
		if(D<=r)
		{
			printf("0\n");
			printf("%d %d\n",(int)X0,(int)Y0);
		}
		else 
		{
			printf("1\n%d %d ",(int)X0,(int)Y0);
			double X=(X0-x)*(D-r)/D+x;
			double Y=(Y0-y)*(D-r)/D+y;
			double mnD=1e18;int ansX,ansY;
//			printf("%lf %lf x:%lf y:%lf\n",D,r,X,Y);
			for(int j=(int)Y-1000;j<=(int)Y+1000;j++)
			{
				for(int i=(int)X-1000;i<=(int)X+1000;i++)
				{
					
//					if(i==-2&&j==2)printf("%lf %lf\n", Dis((double)i,(double)j,X0,Y0),mnD); 
					if(Dis((double)i,(double)j,x,y)<=r&&Dis((double)i,(double)j,X0,Y0)<mnD)
					{
						mnD=Dis((double)i,(double)j,X0,Y0);
//						if(mnD==0)printf("%d %d\n",i,j);
						ansX=i,ansY=j; 
					}
				}
			}
			if(D-r>=100.0)
			{
				for(int j=(int)Y-20;j<=(int)Y+20;j++)
					for(int i=(int)X-100000;i<=(int)X+100000;i++)
						if(Dis((double)i,(double)j,x,y)<=r&&Dis((double)i,(double)j,X0,Y0)<mnD)
						{
							mnD=Dis((double)i,(double)j,X0,Y0);
							ansX=i,ansY=j; 
						}
				for(int j=(int)Y-100000;j<=(int)Y+100000;j++)
					for(int i=(int)X-20;i<=(int)X+20;i++)
						if(Dis((double)i,(double)j,x,y)<=r&&Dis((double)i,(double)j,X0,Y0)<mnD)
						{
							mnD=Dis((double)i,(double)j,X0,Y0);
							ansX=i,ansY=j; 
						}
			}
			printf("%d %d\n",ansX,ansY);
//			printf("mnD:%lf\n",mnD); 
		}
//		puts("!!");
	}

	
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 16ms
memory: 3664kb

input:

3
1 2 1 1 2
3 2 5 -10 3
0 0 1 10 0

output:

0
1 2
1
-10 3 -2 2
1
10 0 1 0

result:

ok correct (3 test cases)

Test #2:

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

input:

1
0 0 1 0 0

output:

0
0 0

result:

ok correct (1 test case)

Test #3:

score: 0
Accepted
time: 524ms
memory: 3716kb

input:

100
-1 0 2 -3 -2
0 -2 2 -2 0
2 -1 1 0 1
-1 -3 1 -1 0
-1 2 2 -1 -1
2 -2 2 0 -3
-2 -3 2 -3 -2
0 1 2 2 1
-1 0 1 -2 -2
2 -2 2 -1 -2
1 2 2 -2 2
-1 2 1 -1 2
-2 1 2 -3 -2
-1 1 1 -1 1
2 2 1 1 -3
2 0 1 -2 -1
-1 2 1 -2 0
2 -2 2 -2 -1
-2 -2 1 1 -2
-1 1 2 2 1
2 -3 1 0 -1
-3 -3 2 2 -1
2 1 1 -1 1
-3 -2 1 -2 -3
0 ...

output:

1
-3 -2 -2 -1
1
-2 0 -1 -1
1
0 1 1 -1
1
-1 0 -1 -2
1
-1 -1 -1 0
1
0 -3 1 -3
0
-3 -2
0
2 1
1
-2 -2 -1 -1
1
-1 -2 0 -2
1
-2 2 -1 2
0
-1 2
1
-3 -2 -2 -1
0
-1 1
1
1 -3 2 1
1
-2 -1 1 0
1
-2 0 -1 1
1
-2 -1 0 -2
1
1 -2 -1 -2
1
2 1 1 1
1
0 -1 1 -3
1
2 -1 -1 -3
1
-1 1 1 1
1
-2 -3 -3 -3
0
-2 -2
0
-2 -2
0
1 -1...

result:

ok correct (100 test cases)

Test #4:

score: 0
Accepted
time: 606ms
memory: 3588kb

input:

100
-5 9 1 -2 -7
3 1 6 9 2
-2 -1 2 -7 3
-10 -8 7 -8 6
0 3 9 -6 -7
6 4 9 -1 4
8 6 7 -7 7
3 -7 7 2 0
-5 -1 6 -7 -7
-5 8 7 -9 -6
-6 -5 5 -10 -9
-7 1 9 7 -2
-4 9 4 8 3
3 -9 6 2 -2
-1 -7 3 -8 2
-2 -5 4 -1 0
1 2 9 -5 5
0 9 5 -4 -1
-10 8 2 -3 -7
-8 -3 3 2 -3
3 3 7 -4 6
6 0 6 -3 5
-7 5 9 9 9
2 0 2 8 -10
2 1...

output:

1
-2 -7 -5 8
1
9 2 9 1
1
-7 3 -4 -1
1
-8 6 -10 -1
1
-6 -7 -4 -5
0
-1 4
1
-7 7 1 6
1
2 0 2 -1
1
-7 -7 -7 -6
1
-9 -6 -5 1
1
-10 -9 -9 -9
1
7 -2 2 1
1
8 3 -1 7
1
2 -2 3 -3
1
-8 2 -3 -5
1
-1 0 -2 -1
0
-5 5
1
-4 -1 -3 5
1
-3 -7 -10 6
1
2 -3 -5 -3
1
-4 6 -3 6
1
-3 5 1 3
1
9 9 1 9
1
8 -10 2 -2
1
7 -1 5 1
0...

result:

ok correct (100 test cases)

Test #5:

score: 0
Accepted
time: 1106ms
memory: 3644kb

input:

100
-52 -13 72 44 58
79 -58 32 60 11
-50 21 75 95 65
-37 -61 21 -74 -40
0 -88 14 11 -49
10 -80 46 79 -17
75 -94 90 61 -34
-80 19 85 -7 -20
-72 42 56 67 -89
21 51 39 20 88
82 32 56 88 -82
3 51 31 -45 -53
50 12 91 9 46
-45 29 25 76 27
-19 -14 81 22 97
5 93 35 98 64
54 90 88 -100 63
-60 -18 81 -20 8
34...

output:

1
44 58 7 28
1
60 11 68 -28
1
95 65 22 42
1
-74 -40 -54 -49
1
11 -49 5 -75
1
79 -17 43 -48
0
61 -34
0
-7 -20
1
67 -89 -30 5
0
20 88
1
88 -82 82 -24
1
-45 -53 -10 23
0
9 46
1
76 27 -20 29
1
22 97 9 62
1
98 64 39 85
1
-100 63 -33 77
0
-20 8
1
62 16 46 51
1
-46 66 -79 -27
1
62 -91 -11 -54
1
-55 -54 73 ...

result:

ok correct (100 test cases)

Test #6:

score: -100
Time Limit Exceeded

input:

100
-14 48 115 -133 160
80 40 30 181 139
114 -109 102 -111 -14
-51 175 113 40 -116
-44 -171 69 6 -128
18 -23 159 94 170
-150 71 199 -167 -181
82 173 50 -138 41
-27 -126 119 195 134
-129 16 169 -103 51
183 136 117 -196 54
25 61 27 166 12
-156 63 199 -8 -56
-143 138 31 -137 125
48 16 44 -83 37
150 -16...

output:


result: