QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#683294 | #5444. Tavern Chess | ssx# | WA | 0ms | 3812kb | C++20 | 2.4kb | 2024-10-27 19:55:00 | 2024-10-27 19:55:01 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
const int N = 1e6 + 50;
const int mod = 998244353;
struct syz{
int a,b,c;
syz(){}
syz(int aa,int bb,int cc):a(aa),b(bb),c(cc)
{}
};
void solve()
{ int n,m;
cin>>n>>m;
vector<int>aa(n),bb(m);
for(int i=0;i<n;++i) cin>>aa[i];
for(int i=0;i<m;++i) cin>>bb[i];
//for(int i=1;i<=n;++i) cerr<<b[i]<<" ";
array<syz,8>a1,a2;
for(int i=0;i<n;++i) a1[i].a=a1[i].b=aa[i],a1[i].c=0;
for(int i=n;i<=7;++i) a1[i]={0,0,0};
for(int i=0;i<m;++i) a2[i].a=a2[i].b=bb[i],a2[i].c=0;
for(int i=m;i<=7;++i) a2[i]={0,0,0};
a1[7].a=1,a2[7].a=0;
//for(int i=0;i<m;++i) cerr<<a2[i].a<<" ";
ll aas=0,las=0,total=0;
auto dfs=[&](auto self,array<syz,8>a,array<syz,8>b){
// cnt++;
//cerr<<cnt<<'\n';
// for(int i=0;i<n;++i) cerr<<a[i].a<<" ";
// cerr<<'\n';
// for(int i=0;i<m;++i) cerr<<b[i].a<<" ";
// cerr<<'\n';
int k=-1,mi=10000;
bool ok1=false,ok2=false;
for(int i=0;i<n;++i){
if(a[i].a<=0) continue;
ok1=true;
if(mi>a[i].c) mi=a[i].c,k=i;
}
if(k==-1){
for(int i=0;i<m;++i){
if(b[i].a<=0) continue;
ok2=true;
}
total++;
if(ok2&&a[7].a) las++;
if(ok2&&!a[7].a) aas++;
return ;
}
a[k].c++;
for(int i=0;i<m;++i){
if(b[i].a<=0) continue;
ok2=true;
a[k].a-=b[i].b;
b[i].a-=a[k].b;
swap(n,m);
self(self,b,a);
swap(n,m);
a[k].a+=b[i].b;
b[i].a+=a[k].b;
}
if(!ok2||!ok1){
total++;
// for(int i=0;i<m;++i) cerr<<a[i].a<<" ";
// cerr<<'\n';
// for(int i=0;i<m;++i) cerr<<b[i].a<<" ";
// cerr<<'\n';
}
if(!ok2){
if(a[7].a) aas++;
else las++;
}
};
dfs(dfs,a1,a2);
cerr<<aas<<" "<<las<<" "<<total<<'\n';
cout<<(1.0*aas)/total<<'\n';
cout<<(1.0*las)/total<<'\n';
cout<<(1.0*total-aas-las)/total<<'\n';
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
ll T = 1;
//cin >> T;
while (T --)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3812kb
input:
2 3 2 5 3 4 1
output:
0.142857 0.285714 0.571429
result:
wrong answer 1st numbers differ - expected: '0.1250000', found: '0.1428570', error = '0.0178570'