QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#221515 | #7617. Spectacle | PhantomThreshold# | WA | 55ms | 10120kb | C++20 | 1.1kb | 2023-10-21 13:38:25 | 2023-10-21 13:38:25 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=200000;
ll n;
ll a[maxn+50];
ll vis[maxn+50];
ll fa[maxn+50];
ll sz[maxn+50];
ll ans[maxn+50];
int main(){
ios_base::sync_with_stdio(false);
cin >> n;
for (int i=1;i<=n;i++) cin >> a[i];
ll lim=n/2;
sort(a+1,a+n+1);
for (int i=1;i<n;i++) a[i]=a[i+1]-a[i];
n--;
map<ll,ll> dict;
for (int i=1;i<=n;i++) dict[a[i]]=i;
function<int(int)> getfa = [&](int x){
return fa[x]==x?x:fa[x]=getfa(fa[x]);
};
ll sum=0;
auto conn = [&](int x,int y){
int fax=getfa(x);
int fay=getfa(y);
if (fax!=fay){
ll sum1=sz[fax];
ll sum2=sz[fay];
fa[fay]=fax;
sz[fax]=sum1+sum2;
sum-=(sum1+1)/2;
sum-=(sum2+1)/2;
sum+=(sum1+sum2+1)/2;
}
};
ll presum=0;
for (auto [x,pos]:dict){
vis[pos]=1;
sz[pos]=1;
fa[pos]=pos;
sum++;
if (vis[pos-1]) conn(pos-1,pos);
if (vis[pos+1]) conn(pos,pos+1);
for (int i=presum+1;i<=sum;i++) ans[i]=x;
presum=sum;
}
for (int i=1;i<=lim;i++) cout << ans[i] << " \n"[i==lim];
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5596kb
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: 1ms
memory: 5648kb
input:
2 1 1000000000000000000
output:
999999999999999999
result:
ok single line: '999999999999999999'
Test #3:
score: -100
Wrong Answer
time: 55ms
memory: 10120kb
input:
200000 30977570544127554 30977570529630987 30977570554040634 30977570903666181 30977570284338326 30977570675313216 30977569987827221 30977570780807305 30977570623822067 30977570207823010 30977569932624714 30977570440962037 30977570343703869 30977570239637322 30977570141845422 30977570372368100 30977...
output:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...
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 1 2 3 4 5 6 7 8 9 10 11 12 1...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'