QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#148800#5444. Tavern Chessblack_iceWA 2ms3904kbC++142.2kb2023-08-23 19:04:172023-08-23 20:29:04

Judging History

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

  • [2023-08-23 20:29:04]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3904kb
  • [2023-08-23 19:04:17]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
const int N = 20;
int a[N],b[N],bla[N],blb[N];
int T,n,m;
double prob1,prob2,prob3;

void attk(int adx,int bdx,int &cnta,int &cntb)
{
    bla[adx] -= b[bdx];
    blb[bdx] -= a[adx];
    if(bla[adx] <= 0)
    {
        cnta--;
    }
    if(blb[bdx] <= 0)
    {
        cntb--;
    }
}

void rec(int adx,int bdx,int &cnta,int & cntb)
{
    if(bla[adx] <= 0)
    {
        cnta++;
    }
    if(blb[bdx] <= 0)
    {
        cntb++;
    }
    bla[adx] += b[bdx];
    blb[bdx] += a[adx];
}

void dfs(int adx,int bdx,int turn,double prob,int cnta,int cntb)
{
    if(!cnta && cntb)
    {
        prob2 += prob;
        return ;
    }
    if(!cntb && cnta)
    {
        prob1 += prob;
        return ;
    }
    if(!cnta && !cntb) 
    {
        prob3 += prob;
        return ;
    }
    if(!turn)
    {
        while(bla[adx] <= 0) adx = (adx + 1) % n;
        for(int j = 0;j < m;j++)
        {
            if(blb[j] > 0)
            {
                int tmp = cntb;
                attk(adx,j,cnta,cntb);
                dfs(adx + 1,bdx,!turn,prob * (1.00 / tmp),cnta,cntb);
                rec(adx,j,cnta,cntb);
            }
        }
    }
    else{
        while(blb[bdx] <= 0) bdx = (bdx + 1) % m;
        for(int i = 0;i < n;i++)
        {
            if(bla[i] > 0)
            {
                int tmp = cnta;
                attk(i,bdx,cnta,cntb);
                dfs(adx,bdx + 1,!turn,prob * (1.00 / tmp),cnta,cntb);
                rec(i,bdx,cnta,cntb);
            }
        }
    }
}

void solve()
{
    cin >> n >> m;
    for(int i = 0;i < n;i++) cin >> a[i];
    for(int i = 0;i < m;i++) cin >> b[i];
    for(int i = 0;i < n;i++) bla[i] = a[i];
    for(int i = 0;i < m;i++) blb[i] = b[i];
    if(n == m)
    {
        dfs(0,0,0,0.5,n,m);
        dfs(0,0,1,0.5,n,m);
    }
    else if(n > m)
    {
        dfs(0,0,0,1.0,n,m);
    }
    else{
        dfs(0,0,1,1.0,n,m);
    }
    cout << setprecision(15) << prob1 << endl << prob2 << endl << prob3 << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    T = 1;
    while(T--)
    {
        solve();
    }
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3884kb

input:

2 3
2 5
3 4 1

output:

0.125
0.75
0.125

result:

ok 3 numbers

Test #2:

score: 0
Accepted
time: 2ms
memory: 3832kb

input:

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

output:

0.241867283950625
0.24186728395062
0.516265432098777

result:

ok 3 numbers

Test #3:

score: 0
Accepted
time: 2ms
memory: 3764kb

input:

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

output:

0
0
0.999999999999997

result:

ok 3 numbers

Test #4:

score: 0
Accepted
time: 1ms
memory: 3868kb

input:

1 7
7
1 1 1 1 1 1 1

output:

0
0
1

result:

ok 3 numbers

Test #5:

score: 0
Accepted
time: 1ms
memory: 3868kb

input:

2 3
736618938 652769331
328875880 97571721 44608905

output:

1
0
0

result:

ok 3 numbers

Test #6:

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

input:

5 4
53585130 731696211 668322278 611205195 158818781
569587984 776042583 745745433 330119007

output:

0.0668402777777778
0.664351851851852
0.26880787037037

result:

ok 3 numbers

Test #7:

score: 0
Accepted
time: 1ms
memory: 3888kb

input:

7 2
578505806 551611151 92903265 403642038 542119417 57334031 307573613
897644535 168524310

output:

0.999999999999999
0
0

result:

ok 3 numbers

Test #8:

score: -100
Wrong Answer
time: 1ms
memory: 3904kb

input:

5 6
113196606 64768263 772808463 787707989 500151952
481840741 676847825 4641268 431386165 847736311 169677832

output:

0.13683359053498
0.522397183641966
0.340769225823056

result:

wrong answer 1st numbers differ - expected: '0.1363232', found: '0.1368336', error = '0.0005104'