提交时间:2022-10-04 11:32:39

运行 ID: 57515

#include<bits/stdc++.h> #define N 5005 using namespace std; int n,a[N],b[N],h[N];double well,ans[N]; struct NIU_KE{int v,id;} t[N]; inline bool cmp(const NIU_KE &x,const NIU_KE &y){return x.v>y.v;} void dfs(int k){ if(k>n){ for(int i(1);i<=n;++i){ t[i].v=h[i]; t[i].id=i; } sort(t+1,t+1+n,cmp); for(int i(1),p(1);i<=n;++i){ ans[t[i].id]+=p*well; if(i<n&&t[i+1].v^t[i].v) ++p; } return; } h[k]=0;dfs(k+1); h[k]=a[k];dfs(k+1); h[k]=b[k];dfs(k+1); h[k]=a[k]+b[k];dfs(k+1); } int main(){ scanf("%d",&n); for(int i(1);i<=n;++i) scanf("%d%d",&a[i],&b[i]); well=pow(0.25,n);dfs(1); for(int i(1);i<=n;++i){ cout<<ans[i]<<endl; } return 0; }