QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#344829 | #6517. Computational Geometry | piaoyun# | WA | 2ms | 38748kb | C++17 | 3.7kb | 2024-03-05 14:40:44 | 2024-03-05 14:40:44 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Double long double
const int MAXN = 1e6 + 10;
const Double eps = 1e-10;
const Double PI = acosl(-1.0);
int N,M,K,Q;
int a[MAXN];
Double torad(Double deg){
return deg / 180 * PI;
}
int dcmp(Double x){
if(fabs(x) < eps) return 0;
else return x < 0 ? -1 : 1;
}
struct Point{
int x,y;
Point(int x=0,int y=0):x(x),y(y){}
void read(){
scanf("%lld %lld",&x,&y);
}
};
typedef vector<Point> Polygon;
typedef Point Vector;
inline Vector operator + (Vector A,Vector B){
return Vector(A.x+B.x,A.y+B.y);
}
inline Vector operator - (Vector A,Vector B){
return Vector(A.x - B.x , A.y - B.y);
}
inline Vector operator * (Vector A,Double p){
return Vector(A.x * p,A.y * p);
}
inline Vector operator / (Vector A,Double p){
return Vector(A.x / p,A.y / p);
}
inline bool operator < (Point A,Point B){
return A.x < B.x || (A.x == B.x && A.y < B.y);
}
inline bool operator == (Point A,Point B){
return dcmp(A.x - B.x) == 0 && dcmp(A.y - B.y) == 0;
}
inline int Dot(Vector A,Vector B){
return A.x * B.x + A.y * B.y;
}
inline int Length(Vector A){
return Dot(A , A);
}
inline Double Angle(Vector A,Vector B){
return acos(Dot(A,B) / Length(A) / Length(B));
}
inline Double angle(Vector v){
return atan2(v.y,v.x);
}
inline Double Cross(Vector A,Vector B){
return A.x * B.y - A.y * B.x;
}
inline Vector Unit(Vector v){
return v / Length(v);
}
inline Vector Normal(Vector v){
return Point(-v.y,v.x) / Length(v);
}
inline Vector Rotate(Vector A, Double rad){
return Vector(A.x * cos(rad) - A.y * sin(rad),A.x * sin(rad) + A.y * cos(rad));
}
inline Double Area2(Point A,Point B,Point C){
return Cross(B - A,C - A);
}
inline Point GetLineIntersection(Point p,Vector v,Point q,Vector w){
Vector u = p - q;
Double t = Cross(v,p-q) / Cross(v,w);
return p + v*t;
}
inline Point GetLineProjection(Point P,Point A,Point B){
Vector v = B - A;
return A + v * (Dot(v,P-A)) / Dot(v,v);
}
inline Double DistanceToLine(Point P,Point A,Point B){
Vector v1 = B - A, v2 = P - A;
return fabs(Cross(v1,v2)) / Length(v1);
}
inline bool OnSegment(Point P,Point A,Point B){
return dcmp(Cross(A-P,B-P)) == 0 && dcmp(Dot(A-P,B-P)) <= 0;
}
inline void getLineGeneralEquation(Point A,Point B,Double &a,Double &b,Double &c){
a = B.y - A.y;
b = A.x - B.x;
c = - a * A.x - b * A.y;
}
Double DistanceToSegment(Point P,Point A,Point B){
if(A == B) return Length(P-A);
Vector v1 = B - A,v2 = P - A,v3 = P-B;
if(dcmp(Dot(v1,v2)) < 0) return Length(v2);
else if(dcmp(Dot(v1,v3)) > 0) return Length(v3);
else return fabs(Cross(v1,v2)) / Length(v1);
}
Point points[2 * MAXN];
int dp[10010][5010];
int query(int l,int r){
if(l > r) r += N;
if(dp[l][r-l]) return dp[l][r-l];
if(l + 1 == r) return Length(points[l] - points[r]);
int ret = query(l,r-1);
for(int i = l;i <= r-1; i++){
ret = max(ret,Length(points[r] - points[i]));
}
return dp[l][r-l] = ret;
}
void prepare(){
scanf("%lld",&N);
for(int i = 1;i <= N; i++) points[i].read();
for(int i = 1;i <= N; i++){
points[i + N] = points[i];
}
for(int i = 1;i <= N; i++){
for(int k = 0; k <= N; k++){
dp[i][k] = 0;
}
}
int ans = 1e18;
for(int i = 1;i <= N; i++){
for(int j = 2;j <= N - 2; j++){
int k = (i + j);if(k > N) k -= N;
ans = min(ans,query(i,k)+query(k,i));
}
}
printf("%lld\n",ans);
}
signed main(){
int T = 1;
scanf("%lld",&T);
while(T--){
prepare();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 38712kb
input:
2 4 1 0 2 0 1 1 0 0 6 10 4 9 7 5 7 4 5 6 4 9 3
output:
4 44
result:
ok 2 number(s): "4 44"
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 38748kb
input:
713 8 8 25 3 15 0 5 10 0 19 2 24 6 23 15 15 34 8 25 16 18 25 10 32 1 23 0 14 21 0 27 2 32 6 7 16 15 8 20 1 16 0 12 16 0 21 1 24 5 7 15 1 18 0 24 8 27 15 4 19 0 17 7 8 4 10 20 0 30 15 0 14 10 6 15 0 24 10 21 14 12 14 7 11 0 3 7 18 7 16 9 12 10 6 9 0 4 5 0 15 1 9 0 23 8 13 14 6 24 0 34 1 41 11 37 20 1...
output:
1075 1389 706 687 1550 497 300 1668 471 162 519 190 786 983 367 930 580 524 509 275 617 298 146 1330 494 965 599 1321 866 1210 233 398 560 1548 871 938 366 500 371 1118 1222 1994 712 586 858 624 697 575 1274 882 1035 406 934 670 990 1231 513 2871 939 2735 1610 834 721 585 203 198 1666 617 1166 326 2...
result:
wrong answer 120th numbers differ - expected: '294', found: '284'