QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#684309#3565. Beer Pressureqqqqq0 1ms3700kbC++231.2kb2024-10-28 12:24:562024-10-28 12:24:58

Judging History

This is the latest submission verdict.

  • [2024-10-28 12:24:58]
  • Judged
  • Verdict: 0
  • Time: 1ms
  • Memory: 3700kb
  • [2024-10-28 12:24:56]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

const int inf=1e9+6;
const int maxn=8;
double gai[maxn];
int temp[maxn];
const int P[]={1,100,10000,1000000,100000000};

int n,k;

void bfs(int x){
	map<int ,double>m;
	m[x]=100.0;
	queue<int>q;
	while(!q.empty()){
		int u=q.front();
		q.pop();
		double pp=m[u];
		int tot=0,tmp=u;
		for(int i=n;i>0;i--){
			temp[i]=tmp%100;
			tmp/=100;
			tot+=temp[i];
		}
		if(tot==k){
			int win[maxn]={0};
			int maxx=temp[1];
			int xuan=0;
			win[xuan++]=1;
			for(int i=2;i<=n;i++){
				if(maxx==temp[i]){
					win[xuan++]=i;
				}else if(temp[i]>maxx){
					maxx=temp[i];
					xuan=0;
					win[xuan++]=i;
				}
			}
			for(int i=0;i<xuan;i++){
				gai[win[i]]+=pp/(double)xuan;
			}
		}else{
			for(int i=n;i>=1;i--){
				int v=u+P[n-i];
				double c=(double)temp[i]/(double)tot;
				auto it=m.find(v);
				if(it==m.end()){
					m[v]=pp*c;
					q.push(v);
				}else{
					it->second+=pp*c;
				}
			}
		}
	}
}

signed main(){
	while(cin>>n>>k){
		int u=0;
		for(int i=0;i<n;i++){
			int t;
			cin>>t;
			u*=100;
			u+=t;
		}
		bfs(u);
		for(int i=1;i<=n;i++){
			printf("pub %d: %.2f %%\n",i,gai[i]);
		}
	}
	
}

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3700kb

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: 0.00 %
pub 2: 0.00 %
pub 3: 0.00 %
pub 1: 0.00 %
pub 1: 0.00 %
pub 1: 0.00 %
pub 2: 0.00 %
pub 1: 0.00 %
pub 2: 0.00 %
pub 1: 0.00 %
pub 2: 0.00 %
pub 1: 0.00 %
pub 2: 0.00 %
pub 3: 0.00 %
pub 1: 0.00 %
pub 2: 0.00 %
pub 3: 0.00 %
pub 1: 0.00 %
pub 2: 0.00 %
pub 3: 0.00 %
pub 1: 0.00 %
pub 2:...

result:

wrong answer 1st lines differ - expected: 'pub 1: 93.33 %', found: 'pub 1: 0.00 %'