QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#404325#6517. Computational GeometrySSAABBEERRWA 1ms3860kbC++201.7kb2024-05-03 20:04:232024-05-03 20:04:26

Judging History

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

  • [2024-05-03 20:04:26]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3860kb
  • [2024-05-03 20:04:23]
  • 提交

answer

#include<bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define ll long long
// #define int long long
#define rep(x,a,b) for(int x=a;x<=b;x++)
#define pre(x,a,b) for(int x=a;x>=b;x--)
#define endl "\n"
#define pb push
#define pii pair<ll,ll>
#define psi pair<string, ll>
#define de cout<<1;
#define mem(a,x) memset(a,x,sizeof a)
#define ls u << 1
#define rs u << 1 | 1
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
const int mod1 = 998244353;
const int mod2 = 1e9 + 7;
const int N = 1e6 + 60;
int n, m, k;
int number;
int x[N], y[N], nx[N], la[N];
double dp[5050][5050];
double c(int a, int b, int c, int d)
{
	return (a - c) * (a - c) + (b - d) * (b - d);
}
double ma(double x, double y, double z)
{
	return max(max(x, y), z);
}
bool check(int a, int b, int c)
{
	double w = (x[a] - x[b]) * (y[a] - y[c]) - (y[a] - y[b]) * (x[a] - x[c]);
	return w != 0;
}
void solve()
{
	cin >> n;
	rep(i, 1, n)
	rep(j, 1, n)
	dp[i][j] = 0;
	rep(i, 1, n) cin >> x[i] >> y[i];
	rep(i, 1, n) nx[i] = (i % n) + 1, la[i] = (i - 1) > 0 ? (i - 1) : n;
	rep(len, 2, n - 1)
	{
		rep(l, 1, n)
		{
			int r = (l + len - 1) % n;
			if(r == 0) r = n;
			dp[l][r] = ma(dp[nx[l]][r], dp[l][la[r]], c(x[l], y[l], x[r], y[r]));
		}
	}//cout<<dp[2][6];
	double ans = 1e9;
	rep(i, 1, n)
	{
		for(int j = nx[i]; j != i; j = nx[j])
		{
			if(j == nx[i] || j == la[i]) continue;
			if(check(i, j, nx[i])) 
			{
				ans = min(ans, dp[i][j] + dp[j][i]);
				//if(ans==16) cout<<i<<" "<<j<<" "<<nx[i]<<endl;
			}
		}
	}
	cout << ans << endl;
}
int main()
{
	IOS;
	int _;
	cin >> _;
	// _ = 1;
	while(_ -- )
	{
		number++;
		solve();
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3824kb

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: 1ms
memory: 3860kb

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'