QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#752162#3565. Beer Pressuregyydp123_LIM0 7ms4668kbC++141.9kb2024-11-15 22:23:072024-11-15 22:23:07

Judging History

This is the latest submission verdict.

  • [2024-11-15 22:23:07]
  • Judged
  • Verdict: 0
  • Time: 7ms
  • Memory: 4668kb
  • [2024-11-15 22:23:07]
  • Submitted

answer

#include<bits/stdc++.h>
#define For(i,j,k) for(int i=(j);i<=(k);++i)
#define ForDown(i,j,k) for(int i=(j);i>=(k);--i)
#define Debug(fmt, args...) fprintf(stderr,"(func %s, line #%d): " fmt,__func__,__LINE__,##args),fflush(stderr)
#define debug(fmt, args...) fprintf(stderr,fmt,##args),fflush(stderr)
#define within :
#define LJY main
using namespace std;
typedef long long ll;
const int N=55;
mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());
inline int read(){
  char ch=getchar();int x=0,f=1;
  while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
  while(ch>='0'&&ch<='9')
    x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
  return x*f;
}
int n,m,a[N],s[N];bool vis[N];
int l[N],r[N];
ll C[N][N];double p[N][N][N];
double f[N][N],ans[N];
void ljy(){
  For(i,1,n) a[i]=read(),ans[i]=0,s[i]=s[i-1]+a[i];
  For(S,1,(1<<n)-1) For(val,1,m){
    int pcnt=__builtin_popcount(S);
    if(pcnt*val>m||pcnt*val+(n-pcnt)*(val-1)<m) continue;
    bool flg=1;For(i,1,n){
      vis[i]=(S>>i-1)&1;
      if(!vis[i]&&a[i]>=val){flg=0;break;}
      if(vis[i]&&a[i]>val){flg=0;break;} 
    }if(!flg) continue;
    r[n]=m;ForDown(i,n-1,0) r[i]=(vis[i+1]?r[i+1]-val:r[i+1]-a[i+1]);
    if(r[0]<0) continue;
    l[0]=0;For(i,1,n) l[i]=l[i-1]+(vis[i]?val:a[i]);l[n]=m;
    memset(f,0,sizeof(f));f[0][0]=1;
    For(i,1,n) For(j,l[i],r[i]) For(k,l[i-1],r[i-1]){
      if(vis[i]&&j-k!=val) continue;
      else if(!vis[i]&&(j-k<a[i]||j-k>=val)) continue;
      f[i][j]=(f[i][j]+f[i-1][k]*C[j-s[i]][j-k-a[i]]*p[a[i]][k-s[i-1]+s[n]][j-k-a[i]]);
    }double res=f[n][m];
    // debug("%d %d %.5lf\n",S,val,res);
    For(i,1,n) if(vis[i]) ans[i]+=res/pcnt;
  }For(i,1,n) printf("pub %d: %.2lf %%\n",i,ans[i]*100.0);
}
signed LJY(){
  For(i,0,50){C[i][0]=1;For(j,1,i) C[i][j]=C[i-1][j-1]+C[i-1][j];}
  For(i,1,50) For(j,i+1,50){
    p[i][j][0]=1;
    For(k,1,50-j) p[i][j][k]=p[i][j][k-1]*(i+k-1)/(j+k-1);
  }while(scanf("%d%d",&n,&m)==2) ljy();
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

score: 0
Wrong Answer
time: 7ms
memory: 4668kb

input:

3 7
3 1 1
1 1
1
1 50
1
2 2
1 1
2 50
1 1
2 50
1 2
3 3
1 1 1
3 50
1 1 1
3 50
1 1 2
4 4
1 1 1 1
4 50
1 1 1 1
4 50
1 1 1 2
5 5
1 1 1 1 1
5 50
1 1 1 1 1
5 50
1 1 1 1 2
4 49
2 10 4 2
4 36
4 3 2 4
3 27
2 6 10
1 16
9
3 43
3 6 3
2 28
6 5
3 37
5 7 9
1 44
1
5 44
8 1 9 8 7
3 46
8 2 6
4 28
4 10 4 9
4 50
1 8 6 4
...

output:

pub 1: 93.33 %
pub 2: 3.33 %
pub 3: 3.33 %
pub 1: 0.00 %
pub 1: 0.00 %
pub 1: 50.00 %
pub 2: 50.00 %
pub 1: 50.00 %
pub 2: 50.00 %
pub 1: 24.49 %
pub 2: 75.51 %
pub 1: 33.33 %
pub 2: 33.33 %
pub 3: 33.33 %
pub 1: 33.33 %
pub 2: 33.33 %
pub 3: 33.33 %
pub 1: 19.01 %
pub 2: 19.01 %
pub 3: 61.98 %
pub ...

result:

wrong answer 4th lines differ - expected: 'pub 1: 100.00 %', found: 'pub 1: 0.00 %'