QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#565795#9308. World CupshumianWA 1ms3640kbC++232.1kb2024-09-15 22:15:522024-09-15 22:15:54

Judging History

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

  • [2024-09-15 22:15:54]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3640kb
  • [2024-09-15 22:15:52]
  • 提交

answer

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

void solve() {
    vector<vector<int>> q(8);
    int mark;

    for(int i = 0; i < 8; ++i) {
        vector<int> num(4);
        for(int j = 0; j < 4; ++j) {
            cin >> num[j];
            if (i == 0 && j == 0) mark = num[j]; // 中国队实力
        }
        sort(num.rbegin(), num.rend());
        q[i] = num;
    }

    vector<int> qq;
    for(auto& group : q) {
        qq.push_back(group[0]); // 头名
        qq.push_back(group[1]); // 次名
    }

    // 检查中国队是否在淘汰赛阶段
    if(find(qq.begin(), qq.end(), mark) == qq.end()) {
        cout << 32 << endl;
        return;
    }

    // 淘汰赛模拟
    vector<int> pp1 = {qq[0], qq[3], qq[4], qq[7], qq[8], qq[11], qq[12], qq[15]};
    vector<int> pp2 = {qq[1], qq[2], qq[5], qq[6], qq[9], qq[10], qq[13], qq[14]};

    int round = 16;
    for(int i = 0; i < 2; ++i) {
        bool flag = false;
        vector<int> next_pp1, next_pp2;

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

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

        if (!flag) {
            cout << round << endl; // 返回当前轮次
            return;
        }
        round /= 2;
    }

    // 最后两队的比较
    int final1 = max(pp1[0], pp1[1]);
    int final2 = max(pp2[0], pp2[1]);

    if (final1 != mark && final2 != mark) {
        cout << 4 << endl; // 半决赛
        return;
    }

    if (final1 == mark || final2 == mark) {
        cout << (final1 == mark ? 1 : 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: 3640kb

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: 1ms
memory: 3588kb

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
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
1

result:

wrong answer 14th numbers differ - expected: '4', found: '8'