QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#211518 | #6412. Classical Geometry Problem | Liberty12619 | WA | 1ms | 3616kb | C++20 | 2.9kb | 2023-10-12 17:36:20 | 2023-10-12 17:36:20 |
Judging History
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;
}
}
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;
}
}
}
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();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3616kb
input:
3 105 255 175 174 174 174 0 0 0
output:
3 0 255 119 281.400071073196 255 255 119 0.000000000000 255 255 255 119.000000000000 4 0 0 0 0.000000000000 255 0 0 0.000000000000 0 255 255 0.000000000000 255 255 255 301.376840516985 1 0 0 0 0.000000000000
result:
wrong answer to[1][3] is equal to neither 0 nor 255 (test case 1)