QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#704411#5444. Tavern Chesssurenjamts#RE 0ms3912kbC++172.0kb2024-11-02 19:55:522024-11-02 19:55:58

Judging History

你现在查看的是最新测评结果

  • [2024-11-02 19:55:58]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3912kb
  • [2024-11-02 19:55:52]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define F first
#define S second
double aa, bb, tt;
vector<int> a(10), b(10);
vector<int> a1(10), b1(10);
void rec(bool alice, int n, int m, double p, vector<int> &a, vector<int> &b, vector<int> &at, vector<int> &bt){
	int neg=0, hoyr=0;
	for(int i=0; i<n; i++){
		if(a[i]>0){
			neg++;
		}
	}
	for(int i=0; i<m; i++){
		if(b[i]>0){
			hoyr++;
		}
	}
	if(neg==0 or hoyr==0){
		if(neg==0 and hoyr==0){
			tt+=p;
			return;
		}
		if(neg==0){
			bb+=p;
		}
		else aa+=p;
		return;
	}
	if(alice){
		int idx=1e9;
		int mn=1e9;
		for(int i=n-1; i>=0; i--){
			if(a[i]<=0) continue;
			if(at[i]<=mn){
				mn=at[i];
				idx=i;
			}
		}
		double huvi=0;
		for(int j=0; j<m; j++){
			if(b[j]>0) huvi+=1.0;
		}
		at[idx]++;
		for(int j=0; j<m; j++){
			if(b[j]<=0) continue;
			b[j]-=a1[idx];
			a[idx]-=b1[j];
			rec(1^alice,n,m,p/huvi,a,b,at,bt);
			b[j]+=a1[idx];
			a[idx]+=b1[j];
		}
		at[idx]--;
	}
	else{
		int idx=1e9;
		int mn=1e9;
		for(int i=n-1; i>=0; i--){
			if(b[i]<=0) continue;
			if(bt[i]<=mn){
				mn=bt[i];
				idx=i;
			}
		}
		double huvi=0;
		for(int j=0; j<m; j++){
			if(a[j]>0) huvi+=1.0;
		}
		bt[idx]++;
		for(int j=0; j<m; j++){
			if(a[j]<=0) continue;
			a[j]-=b1[idx];
			b[idx]-=a1[j];
			rec(1^alice,n,m,p/huvi,a,b,at,bt);
			a[j]+=b1[idx];
			b[idx]+=a1[j];
		}
		bt[idx]--;
	}
}
signed main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n,m;
    cin>>n>>m;
    for(int i=0; i<n; i++){
    	cin>>a[i];
    	a1[i]=a[i];
    }
    for(int i=0; i<m; i++){
    	cin>>b[i];
    	b1[i]=b[i];
	}
	
	vector<int> at(10), bt(10);
	cout<<fixed<<setprecision(18);
	if(n!=m){
		if(n>m){
			rec(1,n,m,1.0,a,b,at,bt);
		}
		else{
			rec(0,n,m,1.0,a,b,at,bt);
		}
	} 
	else{
		double ans=0;
		rec(0,n,m,0.5,a,b,at,bt);
		rec(1,n,m,0.5,a,b,at,bt);
//		cout<<ans<<endl;
	}
	cout<<aa<<endl<<bb<<endl<<tt<<endl;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3912kb

input:

2 3
2 5
3 4 1

output:

0.125000000000000000
0.750000000000000000
0.125000000000000000

result:

ok 3 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

6 6
1 1 4 5 1 4
1 1 4 5 1 4

output:

0.241867283950619821
0.241867283950624734
0.516265432098776511

result:

ok 3 numbers

Test #3:

score: 0
Accepted
time: 0ms
memory: 3720kb

input:

7 7
1 1 1 1 1 1 1
1 1 1 1 1 1 1

output:

0.000000000000000000
0.000000000000000000
0.999999999999996558

result:

ok 3 numbers

Test #4:

score: -100
Runtime Error

input:

1 7
7
1 1 1 1 1 1 1

output:


result: