QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#211545#6412. Classical Geometry ProblemLiberty12619WA 19ms3968kbC++203.2kb2023-10-12 18:09:172023-10-12 18:09:17

Judging History

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

  • [2023-10-12 18:09:17]
  • 评测
  • 测评结果:WA
  • 用时:19ms
  • 内存:3968kb
  • [2023-10-12 18:09:17]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
using namespace std;
const int N = 1e6+10,INF = 1e12,mod = 998244353;
const double eps = 1e-8;
typedef pair<int,int>PII;
struct Node
{
	int x,y,z;
	double d;
};
vector<Node>ans;
void work(int cnt,double x,double y,double z)
{
	if(cnt==3)
	{
		double d = sqrt(x*x+y*y+z*z);
		ans.push_back((Node){x,y,z,d});
		return;
	}
	else if(cnt==2)
	{
		if(x>eps&&(int)x!=255)
		{
			//printf("!!!!!!\n");
			work(3,0,y,z);
			ans.push_back((Node){255,y,z,x});
			return;
		}
		if(y>eps&&(int)y!=255)
		{
			work(3,x,0,z);
			ans.push_back((Node){x,255,z,y});
			return;
		}
		if(z>eps&&(int)z!=255)
		{
			work(3,x,y,0);
			ans.push_back((Node){x,y,255,z});
			return;
		}	
		return;			
	}
	else if(cnt==1)
	{
		if(x<=eps||(int)x==255)
		{
			double tmp = (255-y)/(255-z);
			double yp = y-tmp*z,zp = z-y/tmp;
			if(yp>=-eps)
			{
				work(2,x,yp,0);
				ans.push_back({x,255,255,sqrt((y-yp)*(y-yp)+z*z)});
				return;
			}
			if(zp>=-eps)
			{
				work(2,x,0,zp);
				ans.push_back({x,255,255,sqrt((z-zp)*(z-zp)+y*y)});
				return;
			}			
		}
		if(y<=eps||(int)y==255)
		{
			double tmp = (255-x)/(255-z);
			double xp = x-tmp*z,zp = z-x/tmp;
//			printf("%.12lf %.12lf\n",xp,zp);
//			return;
			if(xp>=-eps)
			{
				work(2,xp,y,0);
				ans.push_back({255,y,255,sqrt((x-xp)*(x-xp)+z*z)});
				return;
			}
			if(zp>=-eps)
			{
				work(2,0,y,zp);
				ans.push_back({255,y,255,sqrt((z-zp)*(z-zp)+x*x)});
				return;
			}			
		}
		if(z<=eps||(int)z==255)
		{
			double tmp = (255-y)/(255-x);
			double yp = y-tmp*x,xp = x-y/tmp;
			//printf("!!!!%.12lf %.12lf\n",x,y);
			if(yp>=-eps)
			{
				work(2,0,yp,z);
				ans.push_back({255,255,z,sqrt((y-yp)*(y-yp)+x*x)});
				return;
			}
			if(xp>=-eps)
			{
				work(2,xp,0,z);
				ans.push_back({255,255,z,sqrt((x-xp)*(x-xp)+y*y)});
				return;
			}			
		}
		return;			
	}
	else
	{
		double xp,yp,zp,tmp;
		tmp = x/(255-x);
		yp = y-tmp*(255-y),zp=z-tmp*(255-z);
		//printf("!!!!%.12lf %.12lf\n",yp,zp);
		//return;
		if(yp>=-eps&&zp>=-eps)
		{
			//cout<<"!!!!\n";
			//return;
			work(1,0,yp,zp);
			ans.push_back({255,255,255,sqrt(x*x+(y-yp)*(y-yp)+(z-zp)*(z-zp))});
			return ;
		}
		//return;
		tmp = y/(255-y);
		xp = x-tmp*(255-x),zp = z-tmp*(255-z);
		//printf("!!!!%.12lf %.12lf\n",xp,zp);
		if(xp>=-eps&&zp>=-eps)
		{
			work(1,xp,0,zp);
			ans.push_back({255,255,255,sqrt(y*y+(x-xp)*(x-xp)+(z-zp)*(z-zp))});
			return;
		}
		tmp = z/(255-z);
		xp = x-tmp*(255-x),yp= y-tmp*(255-y);
		//printf("!!!!%.12lf %.12lf\n",xp,yp);
		if(xp>=-eps&&yp>=-eps)
		{
			work(1,xp,yp,0);
			ans.push_back({255,255,255,sqrt(z*z+(x-xp)*(x-xp)+(y-yp)*(y-yp))});
			return;
		}
	}
	
}
void solve()
{
	int x,y,z;
	ans.clear();
	scanf("%lld%lld%lld",&x,&y,&z);
	int cnt=0;
	if(x==0||x==255)	cnt++;
	if(y==0||y==255)	cnt++;
	if(z==0||z==255)	cnt++;
	work(cnt,x,y,z);
	printf("%lld\n",ans.size());
	for(auto t : ans)	printf("%lld %lld %lld %.12lf\n",t.x,t.y,t.z,t.d);	
}
signed main()
{
	int T =1 ;
	//cin.tie(0)->sync_with_stdio(false);
	cin>>T;
	while(T--)
	{
		solve();
	}
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3968kb

input:

3
105 255 175
174 174 174
0 0 0

output:

3
0 255 0 255.000000000000
0 255 255 119.000000000000
255 255 255 119.000000000000
2
0 255 255 0.000000000000
255 255 255 301.376840516985
1
0 0 0 0.000000000000

result:

ok ok (3 test cases)

Test #2:

score: 0
Accepted
time: 19ms
memory: 3876kb

input:

10000
250 128 13
1 245 2
88 183 138
179 69 194
153 246 33
255 119 192
233 30 108
26 208 33
53 162 189
225 130 10
202 137 121
152 198 25
49 165 180
228 56 30
74 18 14
6 115 31
168 242 206
90 238 139
44 103 60
16 21 190
229 209 68
41 171 181
39 74 73
181 96 18
234 95 70
75 174 84
101 16 44
202 249 80
...

output:

4
0 0 0 0.000000000000
255 0 0 244.960629921260
255 255 0 121.271562481707
255 255 255 14.683872523535
4
0 0 0 0.000000000000
0 255 0 244.920948616601
0 255 255 1.004720917329
255 255 255 1.411981404758
4
0 0 0 0.000000000000
0 255 0 98.076923076923
0 255 255 89.645464491727
255 255 255 113.94958288...

result:

ok ok (10000 test cases)

Test #3:

score: 0
Accepted
time: 19ms
memory: 3968kb

input:

10000
90 173 87
39 251 59
39 43 150
106 29 130
52 55 180
236 225 70
171 15 48
92 133 240
182 226 10
126 139 105
196 7 204
32 131 193
27 96 218
67 29 33
159 9 251
130 111 243
226 69 39
198 131 80
108 169 147
45 36 170
76 138 251
55 235 186
224 165 48
51 133 173
225 14 226
234 70 139
178 92 174
138 24...

output:

4
0 0 0 0.000000000000
0 255 0 128.272727272727
255 255 0 5.084891638575
255 255 255 129.125162988616
4
0 0 0 0.000000000000
0 255 0 249.795918367347
0 255 255 23.616027532010
255 255 255 52.667780110124
4
0 0 0 0.000000000000
0 0 255 128.702830188679
0 255 255 5.269681089669
255 255 255 57.84121950...

result:

ok ok (10000 test cases)

Test #4:

score: -100
Wrong Answer
time: 19ms
memory: 3920kb

input:

10000
186 217 161
76 0 116
246 159 161
32 245 65
206 120 71
217 76 204
109 255 245
157 59 192
55 35 87
27 147 199
190 134 31
169 64 105
5 27 255
161 2 35
244 255 232
253 106 199
28 151 129
50 24 20
172 236 234
74 51 150
179 68 178
69 42 192
152 1 23
177 169 71
216 190 125
136 223 193
255 168 49
74 2...

output:

4
0 0 0 0.000000000000
0 255 0 114.565217391304
255 255 0 77.423738456576
255 255 255 210.056622440367
3
0 0 0 0.000000000000
0 0 255 56.983240223464
255 0 255 96.223583047616
4
0 0 0 0.000000000000
255 0 0 230.585106382979
255 0 255 5.336794410424
255 255 255 223.028684131240
4
0 0 0 0.000000000000...

result:

wrong answer too far from the target: (167.381799, 167.381799, 167.381799) instead of (205, 205, 255) (test case 2750)