QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#554022 | #2754. Playing the Slots | Tenshi# | WA | 0ms | 3872kb | C++20 | 2.5kb | 2024-09-09 01:59:21 | 2024-09-09 01:59:21 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << ": " << (x) << endl
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define dwn(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define x first
#define y second
using pii = pair<int, int>;
using ll = long long;
inline void read(int &x){
int s=0; x=1;
char ch=getchar();
while(ch<'0' || ch>'9') {if(ch=='-')x=-1;ch=getchar();}
while(ch>='0' && ch<='9') s=(s<<3)+(s<<1)+ch-'0',ch=getchar();
x*=s;
}
const double eps=1e-8, pi=acos(-1);
/*start-----------------------------------------------------------------*/
struct Point{
double x, y;
Point(double x=0, double y=0): x(x), y(y){}
};
typedef Point Vector;
Vector operator + (Vector A, Vector B){return Vector(A.x+B.x, A.y+B.y);}
Vector operator - (Vector A, Vector B){return Vector(A.x-B.x, A.y-B.y);}
Vector operator * (Vector A, Vector B){return Vector(A.x*B.x, A.y*B.y);}
Vector operator / (Vector A, Vector B){return Vector(A.x/B.x, A.y/B.y);}
int sign(double x){
if(fabs(x)<eps) return 0;
return x<0? -1: 1;
}
int cmp(double x, double y){
return sign(x-y);
}
bool operator < (const Point &a, const Point &b) {
return sign(a.x-b.x)<0 || sign(sign(a.x-b.x)==0 && sign(a.y-b.y)<0);
}
double dot(Vector A, Vector B){
return A.x*B.x+A.y*B.y;
}
double cross(Vector A, Vector B){
return A.x*B.y-A.y*B.x;
}
double get_length(Vector A){
return sqrt(dot(A, A));
}
double get_dist(Point a, Point b){
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
double get_angle(Vector A, Vector B){
return acos(dot(A, B)/get_length(A)/get_length(B));
}
double area(Point a, Point b, Point c){
return cross(b-a, c-a);
}
double displ(Point a, Point b, Point c){
double s=abs(area(a, b, c));
double d=get_dist(b, c);
return s/d;
}
Point pt[110];
int n;
bool chk(Point a, Point b, Point c){
return !cmp( (c.y-a.y)*(b.x-a.x), (b.y-a.y)*(c.x-a.x) );
}
signed main(){
cin>>n;
int tot=0;
rep(i, 1, n){
++tot;
cin>>pt[tot].x>>pt[tot].y;
if(i>1 && !cmp(pt[i].x, pt[i-1].x) && !cmp(pt[i].y, pt[i-1].y)) tot--;
if(tot>=3 && chk(pt[tot], pt[tot-1], pt[tot-2])) pt[tot-1]=pt[tot], tot--;
}
n=tot;
double res=1e9;
rep(i, 1, n){
double t=0;
rep(j, 1, n){
int k=j%n+1;
t=max(t, displ(pt[i], pt[j], pt[k]));
}
// debug(t);
res=min(res, t);
}
printf("%.2lf\n", res);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3872kb
input:
3 0 0 0.71 3.54 4.21 4.21
output:
2.00
result:
ok found '2.00000', expected '2.00000', error '0.00000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
6 10 12.5 10 17.5 15 20 20 17.5 20 12.5 15 10
output:
8.94
result:
ok found '8.94000', expected '8.94000', error '0.00000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
4 0 0 0 100 100 100 100 0
output:
100.00
result:
ok found '100.00000', expected '100.00000', error '0.00000'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3824kb
input:
4 1 0 0 1 99 100 100 99
output:
140.01
result:
wrong answer 1st numbers differ - expected: '1.41000', found: '140.01000', error = '98.29787'