QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#704430 | #5444. Tavern Chess | surenjamts# | RE | 6ms | 4068kb | C++17 | 2.0kb | 2024-11-02 19:57:50 | 2024-11-02 19:57:53 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3844kb
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: 6ms
memory: 4068kb
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: 3ms
memory: 3856kb
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