QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#211523#6412. Classical Geometry ProblemLiberty12619WA 16ms3860kbC++203.0kb2023-10-12 17:43:102023-10-12 17:43:10

Judging History

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

  • [2023-10-12 17:43:10]
  • 评测
  • 测评结果:WA
  • 用时:16ms
  • 内存:3860kb
  • [2023-10-12 17:43:10]
  • 提交

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;
	}
	if(cnt==2)
	{
		if(x>eps&&(int)x!=255)
		{
			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;			
	}
	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;
			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)+z*z)});
				return;
			}			
		}
		return;			
	}
	double xp,yp,zp,tmp;
	tmp = x/(255-x);
	yp = y-tmp*(255-y),zp=z-tmp*(255-z);
	//printf("%lld %.12lf\n",(int)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);
	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);
	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: 3816kb

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: -100
Wrong Answer
time: 16ms
memory: 3860kb

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 4.770775037418
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.9495828873...

result:

wrong answer too far from the target: (245.553064, 15.047814, 10.476586) instead of (250, 128, 13) (test case 1)