QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#605417#5444. Tavern ChessDetach#WA 1ms3896kbC++173.7kb2024-10-02 17:09:562024-10-02 17:09:57

Judging History

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

  • [2024-10-02 17:09:57]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3896kb
  • [2024-10-02 17:09:56]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include <algorithm>
// #include <queue>
// #include <map>
// #include <iostream>
// #include <string>
// #include <set>
#define endl '\n'
// #define int long long

using namespace std;
using namespace __gnu_pbds;

using LL = long long; 
using PII = pair<int, int>;
using i128 = __int128_t;
using ULL = unsigned long long;
using Tree = tree<PII, null_type, less<PII>, rb_tree_tag, tree_order_statistics_node_update>;

constexpr int INF = 0x3f3f3f3f, MOD = 1e9 + 7, N = 10, M = 1e6 + 5;
constexpr LL LINF = 0x3f3f3f3f3f3f3f3f;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, m;
int atk[N], ahp[N], btk[N], bhp[N], ause[N], buse[N];
int acnt, bcnt;

double ali, bob, dra;

void dfs(int now, double p) {
    if(acnt == 0 and bcnt == 0) { dra += p; return; }
    else if(acnt == 0) { bob += p; return; }
    else if(bcnt == 0) { ali += p; return; }

    if(now == 1) {
        int mn = INF, cnt = 0;
        for(int i = 0; i < n; i ++) {
            if(ahp[i] <= 0) continue;

            mn = min(mn, ause[i]);
        }
        for(int i = 0; i < m; i ++) {
            if(bhp[i] > 0) cnt ++ ;
        }
        for(int i = 0; i < n; i ++) {
            if(ahp[i] <= 0 or ause[i] > mn) continue;

            for(int j = 0; j < m; j ++) {
                if(bhp[j] <= 0) continue;

                bhp[j] -= atk[i], ahp[i] -= btk[j];
                if(bhp[j] <= 0) bcnt -- ;
                if(ahp[i] <= 0) acnt -- ;
                ause[i] ++ ;
                dfs(2, p * 1.0 / cnt);
                if(bhp[j] <= 0) bcnt ++ ;
                if(ahp[i] <= 0) acnt ++ ;
                ause[i] -- ;
                bhp[j] += atk[i], ahp[i] += btk[j];
            }
            break;
        }
    } else {
        int mn = INF, cnt = 0;
        for(int i = 0; i < m; i ++) {
            if(bhp[i] <= 0) continue;

            mn = min(mn, buse[i]);
        }
        for(int i = 0; i < n; i ++) {
            if(ahp[i] > 0) cnt ++ ;
        }
        for(int i = 0; i < m; i ++) {
            if(bhp[i] <= 0 or buse[i] > mn) continue;

            for(int j = 0; j < n; j ++) {
                if(ahp[j] <= 0) continue;

                ahp[j] -= btk[i], bhp[i] -= atk[j];
                if(bhp[i] <= 0) bcnt -- ;
                if(ahp[j] <= 0) acnt -- ;
                buse[i] ++ ;
                dfs(1, p * 1.0 / cnt);
                if(bhp[i] <= 0) bcnt ++ ;
                if(ahp[j] <= 0) acnt ++ ;
                buse[i] -- ;
                ahp[j] += btk[i], bhp[i] += atk[j];
            }
            break;
        }
    }
}

void solve()    
{   
    cin >> n >> m;
    acnt = n, bcnt = m;

    for(int i = 0; i < n; i ++) {
        cin >> atk[i];
        ahp[i] = atk[i];
    }

    for(int i = 0; i < m; i ++) {
        cin >> btk[i];
        bhp[i] = btk[i];
    }
    
    if(acnt > bcnt) { dfs(1, 1); }
    else if(acnt < bcnt) { dfs(2, 1); }
    else {
        dfs(1, 0.5);
        dfs(2, 0.5);
    }
    
    // int tot = ali + bob + dra;
    // cerr << ali << ' ' << bob << ' ' << dra << ' ' << tot << endl;
    // cout << 1.0 * ali / tot << endl << 1.0 * bob / tot << endl << 1.0 * dra / tot << endl;
    cout << ali << endl << bob << endl << dra << endl;
}

signed main()
{
    // (.*)   "$1"
    // freopen("park.in", "r", stdin);
    // freopen("park.out", "w", stdout);
	cout << fixed << setprecision(8);
    // srand(NULL);
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int T = 1;
	// cin >> T;

    while(T -- )
        solve();

    // fclose(stdin);
    // fclose(stdout);
    return 0;
}

詳細信息

Test #1:

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

input:

2 3
2 5
3 4 1

output:

0.12500000
0.75000000
0.12500000

result:

ok 3 numbers

Test #2:

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

input:

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

output:

0.24186728
0.24186728
0.51626543

result:

wrong answer 1st numbers differ - expected: '0.2418673', found: '0.2418673', error = '0.0000000'