QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#756575 | #9576. Ordainer of Inexorable Judgment | chenxinghan | WA | 0ms | 4368kb | C++20 | 5.4kb | 2024-11-16 21:00:44 | 2024-11-16 21:00:44 |
Judging History
你现在查看的是最新测评结果
- [2024-12-23 14:23:26]
- hack成功,自动添加数据
- (/hack/1303)
- [2024-12-06 11:32:56]
- hack成功,自动添加数据
- (/hack/1271)
- [2024-11-16 21:00:44]
- 提交
answer
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
const int N = 110;
const double eps = 1e-12;
const double pi = acos(-1.0);
double n, x, y, d, t;
struct Point{
double x, y;
Point() :x(0), y(0) {}
Point(double xx, double yy) :x(xx), y(yy) {}
} p[N];
struct Line{
Point s, e;
Line() :s(Point()), e(Point()) {}
Line(Point xx, Point yy) :s(xx), e(yy) {}
} a[N], q[N];
Point operator+(Point a, Point b){
return Point(a.x+b.x, a.y+b.y);
}
Point operator-(Point a, Point b){
return Point(a.x-b.x, a.y-b.y);
}
Point operator*(Point a, double t){
return Point(a.x*t, a.y*t);
}
double operator*(Point a, Point b){
return a.x*b.y - a.y*b.x;
}
double angle(Line& a){
return std::atan2(a.e.y-a.s.y, a.e.x-a.s.x);
}
int main()
{
std::cin >> n >> x >> y >> d >> t;
Point o(0, 0);
std::cin >> p[1].x >> p[1].y;
Point maxpoint = p[1], minpoint = p[1];
Line maxline(o, p[1]), minline(o, p[1]);
//std::cout << angle(minline) << '\n';
for(int i=2; i<=n; i++){
std::cin >> p[i].x >> p[i].y;
Line tmp(o, p[i]);
//std::cout << angle(tmp) << '\n';
if(angle(tmp) > angle(maxline)){
maxpoint = p[i];
maxline = tmp;
}
if(angle(tmp) < angle(minline)){
minpoint = p[i];
minline = tmp;
}
}
double maxd = std::sqrt(maxpoint.x*maxpoint.x+maxpoint.y*maxpoint.y-d*d);
double maxa = (std::asin(d/sqrt(maxpoint.x*maxpoint.x+maxpoint.y+maxpoint.y)) + angle(maxline));
//std::cout << maxa << '\n';
Point maxcut(maxd*std::cos(maxa), maxd*std::sin(maxa));
if(std::fabs(maxcut.x) < eps) maxcut.x = 0; if(std::fabs(maxcut.y) < eps) maxcut.y = 0;
//std::cout << maxcut.x << ' ' << maxcut.y << '\n';
double mind = std::sqrt(minpoint.x*minpoint.x+minpoint.y*minpoint.y-d*d);
double mina = (angle(minline) - std::asin(d/sqrt(minpoint.x*minpoint.x+minpoint.y*minpoint.y)));
Point mincut(maxd*std::cos(mina), maxd*std::sin(mina));
//std::cout << std::fixed << std::setprecision(12) << mincut.x << ' ' << std::max(eps, mincut.x) << '\n';
if(std::fabs(mincut.x) < eps) mincut.x = 0; if(std::fabs(mincut.y) < eps) mincut.y = 0;
//std::cout << mincut.x << ' ' << mincut.y << '\n';
maxline = Line(o, maxcut); minline = Line(o, mincut);
double ans = 0;
int k=0;
double a1 = angle(maxline), a2 = angle(minline);
if(t > 2*pi){
k = int(t/2/pi);
if(a1 * a2 >= 0) ans += std::fabs(a1-a2)*k;
else ans += (a1+a2)*k;
}
//std::cout << ans << '\n';
if(maxcut.x >= 0 && mincut.y >= 0){
if(mincut.x >= 0 && mincut.y >= 0){
if(t >= a2){
if(t > a1) ans += std::fabs(a1-a2);
else ans += std::fabs(t-a2);
}
} else if(mincut.x >= 0 && mincut.y < 0){
if(t > a1){
if(t >= 2*pi+a2){
ans += a1 + std::fabs(t-2*pi-a2);
} else ans += a1;
} else ans += t;
} else if(mincut.x < 0 && mincut.y >= 0){
//no case
} else{
if(t > a1){
if(t >= 2*pi+a2){
ans += a1 + std::fabs(t-2*pi-a2);
} else ans += a1;
} else ans += t;
}
} else if(maxcut.x >= 0 && mincut.y < 0){
if(mincut.x >= 0 && mincut.y >= 0){
// no case
} else if(mincut.x >= 0 && mincut.y < 0){
if(t > 2*pi+a2){
if(t > 2*pi+a1) ans += std::fabs(a1-a2);
else ans += std::fabs(t-2*pi-a2);
}
} else if(mincut.x < 0 && mincut.y >= 0){
// no case
} else{
if(t > 2*pi+a2){
if(t > 2*pi+a1) ans += std::fabs(a1-a2);
else ans += std::fabs(t-2*pi-a2);
}
}
} else if(maxcut.x < 0 && mincut.y >= 0){
if(mincut.x >= 0 && mincut.y >= 0){
if(t >= a2){
if(t <= a1) ans += t-a2;
else ans += a1-a2;
}
} else if(mincut.x >= 0 && mincut.y < 0){
if(t > a1){
if(t >= 2*pi+a2){
ans += a1 + (t-2*pi-a2);
} else ans += a1;
} else ans += t;
} else if(mincut.x < 0 && mincut.y >= 0){
if(t >= a2){
if(t > a1) ans += a1-a2;
else ans += t-a2;
}
} else{
if(t > a1){
if(t >= 2*pi+a2){
ans += a1 + (t-2*pi-a2);
} else ans += a1;
} else ans += t;
}
} else{
if(mincut.x >= 0 && mincut.y >= 0){
// no case
} else if(mincut.x >= 0 && mincut.y < 0){
// no case
} else if(mincut.x < 0 && mincut.y >= 0){
// no case
} else{
if(t > 2*pi+a2){
if(t > 2*pi+a1) ans += std::fabs(a1-a2);
else ans += std::fabs(t-2*pi-a2);
}
}
}
std::cout << std::fixed << std::setprecision(12) << ans;
//std::cout << angle(maxline)/pi << '\n';
//std::cout << maxpoint.x << ' ' << maxpoint.y << '\n';
//std::cout << minpoint.x << ' ' << minpoint.y << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4272kb
input:
3 1 0 1 1 1 2 2 1 2 2
output:
1.000000000000
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 4364kb
input:
3 1 0 1 2 1 2 2 1 2 2
output:
1.570796326795
result:
ok found '1.5707963', expected '1.5707963', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 4276kb
input:
3 1 0 1 10000 1 2 2 1 2 2
output:
2500.707752257475
result:
ok found '2500.7077523', expected '2500.7077523', error '0.0000000'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 4368kb
input:
3 10000 10000 1 10000 10000 9999 10000 10000 9999 10000
output:
0.430984988104
result:
wrong answer 1st numbers differ - expected: '0.3842413', found: '0.4309850', error = '0.0467437'