QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#236194 | #7617. Spectacle | ucup-team1196# | WA | 53ms | 12536kb | C++23 | 1.3kb | 2023-11-03 18:01:42 | 2023-11-03 18:01:44 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
void solve() {
int n;
cin >> n;
vector<int> fa(n + 1), a(n + 1);
vector<int> is(n + 1);
for(int i = 1; i <= n; i++) {
cin >> a[i];
fa[i] = i;
is[i] = true;
}
struct Node {
int x, y, val;
bool operator < (const Node a) const {
return val < a.val;
};
};
vector<Node> Edges(n);
sort(a.begin() + 1, a.end());
for(int i = 1; i < n; i++) {
Edges[i] = {i, i + 1, a[i + 1] - a[i]};
}
sort(Edges.begin() + 1, Edges.end());
function<int(int)> findf = [&](int x) {
if(x == fa[x]) {
return x;
} return fa[x] = findf(fa[x]);
};
for(int i = 1; i < n; i++) {
auto [x, y, val] = Edges[i];
x = findf(x), y = findf(y);
if(x != y) {
if(is[x] && is[y]) {
cout << val << ' ';
}
fa[x] = y;
is[y] ^= 1;
}
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
// freopen("1.in", "r", stdin);
int t = 1;
// cin >> t;
while(t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
input:
6 100 13 20 14 10 105
output:
1 5 6
result:
ok single line: '1 5 6 '
Test #2:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
2 1 1000000000000000000
output:
999999999999999999
result:
ok single line: '999999999999999999 '
Test #3:
score: -100
Wrong Answer
time: 53ms
memory: 12536kb
input:
200000 30977570544127554 30977570529630987 30977570554040634 30977570903666181 30977570284338326 30977570675313216 30977569987827221 30977570780807305 30977570623822067 30977570207823010 30977569932624714 30977570440962037 30977570343703869 30977570239637322 30977570141845422 30977570372368100 30977...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 ...
result:
wrong answer 1st lines differ - expected: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...99 9999 10000 10000 10000 10000', found: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...998 9999 9999 9999 10000 10000 '