QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#89355#5251. ConstellationsmolarsuWA 6220ms151220kbC++201.6kb2023-03-19 20:39:082023-03-19 20:39:11

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-19 20:39:11]
  • 评测
  • 测评结果:WA
  • 用时:6220ms
  • 内存:151220kb
  • [2023-03-19 20:39:08]
  • 提交

answer

#include<bits/stdc++.h>
#define ri register int
#define fu(i, a, b) for(ri i = (a), ed = (b); i <= ed; ++i)
#define fd(i, a, b) for(ri i = (a), ed = (b); i >= ed; --i)
using namespace std;
#define int long long
const int N = 5e3 + 5;
const double eps = 1e-6;
const int INF = 0x3f3f3f3f3f3f3f3f;
int read() {
	int f = 1, x = 0; char ch = getchar();
	while (ch > '9' || ch < '0') { if (ch == '-')f = -1; ch = getchar(); }
	while (ch <= '9' && ch >= '0') { x = (x << 1) + (x << 3) + (ch ^ 48);  ch = getchar(); }
	return x * f;
}
long double dis[N][N];
struct Node {
	int x, y, rk, sz;
}a[N];
bool vis[N];

signed main() {
	int n = read();
	vector<int> vec;
	fu(i, 1, n) a[i].x = read(), a[i].y = read(), a[i].rk = i, a[i].sz = 1, vec.push_back(i);

	fu(i, 1, n) fu(j, 1, n) dis[i][j] = (a[i].x - a[j].x) * (a[i].x - a[j].x) + (a[i].y - a[j].y) * (a[i].y - a[j].y);
	int tot = n;
	fd(_, n - 1, 1) {
		int x = 0, y = 0;
		long double mi = INF;
		fu(i, 0, signed(vec.size()) - 1) {
			int u = a[vec[i]].rk;
			fu(j, i + 1, signed(vec.size()) - 1) {
				int v = a[vec[j]].rk;
				if (1.0 * dis[u][v] / a[u].sz / a[v].sz - mi < eps) x = i, y = j, mi = dis[u][v] / a[u].sz / a[v].sz;
			}
		}
		//cout << x << ' ' << y << endl;
		tot++;
		int u = vec[x], v = vec[y];
		a[tot].sz = a[u].sz + a[v].sz;
		a[tot].rk = tot;

		vec.erase(vec.begin() + y);
		vec.erase(vec.begin() + x);
		fu(i, 0, signed(vec.size()) - 1) {
			int now = a[vec[i]].rk;
			dis[now][tot] = dis[tot][now] = dis[now][u] + dis[now][v];
		}

		vec.push_back(tot);
		printf("%lld\n", a[tot].sz);

	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3584kb

input:

2
0 0
1 0

output:

2

result:

ok single line: '2'

Test #2:

score: -100
Wrong Answer
time: 6220ms
memory: 151220kb

input:

2000
1000 -1000
1000 -999
1000 -998
1000 -997
1000 -996
1000 -995
1000 -994
1000 -993
1000 -992
1000 -991
1000 -990
1000 -989
1000 -988
1000 -987
1000 -986
1000 -985
1000 -984
1000 -983
1000 -982
1000 -981
1000 -980
1000 -979
1000 -978
1000 -977
1000 -976
1000 -975
1000 -974
1000 -973
1000 -972
1000...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

wrong answer 1969th lines differ - expected: '80', found: '96'