QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#565801#9308. World CupshumianWA 0ms3680kbC++232.3kb2024-09-15 22:16:512024-09-15 22:16:52

Judging History

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

  • [2024-09-15 22:16:52]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3680kb
  • [2024-09-15 22:16:51]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;

void solve() {
    vector<int> strengths(32);
    for (int i = 0; i < 32; ++i) {
        cin >> strengths[i];
    }

    // 中国队的实力
    int mark = strengths[0];
    
    // 小组赛阶段
    vector<int> group_winners(8), group_runners(8);
    for (int i = 0; i < 8; ++i) {
        vector<int> group = {strengths[i * 4], strengths[i * 4 + 1], strengths[i * 4 + 2], strengths[i * 4 + 3]};
        sort(group.rbegin(), group.rend());
        group_winners[i] = group[0];
        group_runners[i] = group[1];
    }

    // 检查中国队是否晋级
    bool advanced_to_knockouts = false;
    for (int i = 0; i < 8; ++i) {
        if (group_winners[i] == mark || group_runners[i] == mark) {
            advanced_to_knockouts = true;
            break;
        }
    }
    
    if (!advanced_to_knockouts) {
        cout << 32 << endl;
        return;
    }

    // 淘汰赛阶段
    vector<int> knockout_winners;
    for (int i = 0; i < 8; ++i) {
        if (i % 2 == 0) {
            knockout_winners.push_back(max(group_winners[i], group_runners[i / 2 + 1])); // A1 vs B2
        } else {
            knockout_winners.push_back(max(group_winners[i], group_runners[i / 2])); // B1 vs A2
        }
    }

    // 继续淘汰赛
    int round = 16;
    for (int i = 0; i < 3; ++i) {
        bool mark_in_this_round = false;
        vector<int> next_round_winners;

        for (int j = 0; j < knockout_winners.size(); j += 2) {
            int winner = max(knockout_winners[j], knockout_winners[j + 1]);
            if (winner == mark) mark_in_this_round = true;
            next_round_winners.push_back(winner);
        }
        knockout_winners = next_round_winners;

        if (!mark_in_this_round) {
            cout << round << endl;
            return;
        }
        round /= 2;
    }

    // 最后两支队伍的比较
    int final1 = max(knockout_winners[0], knockout_winners[1]);
    
    if (final1 == mark) {
        cout << 1 << endl; // 决赛
    } else {
        cout << 2 << endl; // 亚军
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3680kb

input:

32
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
2 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
3 1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
4 1 2 3 5 6 7 8 9 10 11 12 13 14 15 ...

output:

32
32
16
16
16
16
16
8
8
8
8
8
8
8
8
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
1

result:

wrong answer 7th numbers differ - expected: '8', found: '16'