QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#252749 | #7617. Spectacle | Saya_Alter# | WA | 1ms | 7488kb | C++14 | 1.2kb | 2023-11-16 09:49:00 | 2023-11-16 09:49:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
typedef long long LL;
int n, fa[N], sze[N], ans[N]; LL a[N];
struct edge {
int u, v; LL val;
bool operator < (const edge &g) const {
return val < g.val;
}
} e[N];
int find(int u) {
return fa[u] == u ? u : fa[u] = find(fa[u]);
}
int main() {
cin.tie(0)->sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i], fa[i] = i, sze[i] = 1;
sort(a + 1, a + n + 1);
for (int i = 2; i <= n; i++) e[i - 1] = (edge){i - 1, i, a[i] - a[i - 1]};
sort(e + 1, e + n); e[n].val = -1;
int res = 0, las = 0;
for (int i = 1; i <= n; i++) {
//cerr << i << " " << e[i].u << ' ' << e[i].v << " " << e[i].val << endl;
if (e[i].val != e[i - 1].val) {
for (int j = las + 1; j <= res; j++) ans[j] = e[i - 1].val;
las = res;
}
int fu = find(e[i].u), fv = find(e[i].v);
res -= (sze[fu] / 2) + (sze[fv] / 2);
res += (sze[fu] + sze[fv]) / 2;
//cout << fu << ' ' << fv << ' ' << res << "====\n";
fa[fv] = fu, sze[fu] += sze[fv];
}
for (int i = 1; i <= res; i++) cout << ans[i] << ' ';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7488kb
input:
6 100 13 20 14 10 105
output:
1 5 6
result:
ok single line: '1 5 6 '
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 5412kb
input:
2 1 1000000000000000000
output:
-1486618625
result:
wrong answer 1st lines differ - expected: '999999999999999999', found: '-1486618625 '