QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#722110 | #7617. Spectacle | inksamurai# | WA | 66ms | 15784kb | C++23 | 2.1kb | 2024-11-07 17:51:14 | 2024-11-07 17:51:16 |
Judging History
answer
#include <bits/stdc++.h>
#define int ll
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define vec(...) vector<__VA_ARGS__>
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}
struct dsu{
int _n;
vi si,par,leb;
dsu(int n=0){
init(n);
}
void init(int n=0){
_n=n;
par=vi(_n,0);
si=vi(_n,0);
leb=vi(_n,-1);
rep(i,n){
si[i]=1;
par[i]=i;
}
}
int parent(int u){return par[u]=(par[u]==u?u:parent(par[u]));}
bool same(int u,int v){return parent(u)==parent(v);}
void merge(int u,int v){
u=parent(u),v=parent(v);
if(!same(u,v)){
if(si[u]<si[v]) swap(u,v);
leb[u]=max(leb[u],leb[v]);
_n-=1;
si[u]+=si[v];
par[v]=u;
}
}
int size(int v=-1){return v==-1?_n:si[parent(v)];}
};
const int inf=1e18;
void slv(){
int n;
cin>>n;
vi a(n);
rep(i,n){
cin>>a[i];
}
sort(all(a));
vec(pii) evs;
rep(i,n-1){
evs.pb({a[i+1]-a[i],i});
}
sort(all(evs));
dsu uf(n);
vi usd(n);
int now=0;
auto merge=[&](int i,int j){
if(uf.same(i,j)) return;
now-=uf.size(i)/2;
now-=uf.size(j)/2;
uf.merge(i,j);
now+=uf.size(i)/2;
};
vi dp(n+1,inf);
rep(i,sz(evs)){
auto [d,pos]=evs[i];
vi delay;
while(i<sz(evs) and evs[i].fi==d){
delay.pb(evs[i].se);
usd[evs[i].se]=1;
usd[evs[i].se+1]=1;
i+=1;
}
for(auto j:delay){
if(j-1>=0 and usd[j-1]){
merge(j-1,j);
}
if(j+1<n and usd[j+1]){
merge(j,j+1);
}
}
// if(d==5){
// rep(j,n) cout<<uf.parent(j)<<" ";
// print();
// }
dp[now]=min(dp[now],d);
i-=1;
}
per(i,n-1){
dp[i]=min(dp[i],dp[i+1]);
}
rng(i,1,n/2+1){
cout<<dp[i]<<" ";
}
print();
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0);
int t;
// cin>>t;
t=1;
rep(cs,t){
slv();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
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: 3600kb
input:
2 1 1000000000000000000
output:
999999999999999999
result:
ok single line: '999999999999999999 '
Test #3:
score: -100
Wrong Answer
time: 66ms
memory: 15784kb
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 ...97 9999 9999 10000 10000 10000 '