QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#684313#3565. Beer Pressureqqqqq0 0ms0kbC++231.3kb2024-10-28 12:27:092024-10-28 12:27:10

Judging History

This is the latest submission verdict.

  • [2024-10-28 12:27:10]
  • Judged
  • Verdict: 0
  • Time: 0ms
  • Memory: 0kb
  • [2024-10-28 12:27:09]
  • 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;
	q.push(x);
	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){
		memset(gai,0,sizeof(gai));
		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]);
		}
	}
	
}

詳細信息


Pretests


Final Tests

Test #1:

score: 0
Time Limit Exceeded

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: 100.00 %
pub 1: 100.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 %
...

result: