QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#565752#9308. World CupshumianWA 0ms3840kbC++232.1kb2024-09-15 22:09:122024-09-15 22:09:12

Judging History

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

  • [2024-09-15 22:09:12]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3840kb
  • [2024-09-15 22:09:12]
  • 提交

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;
    bool foundMark = false;
    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(8), pp2(8);
    pp1 = {qq[0], qq[3], qq[4], qq[7], qq[8], qq[11], qq[12], qq[15]};
    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> pp3, pp4;

        // 第一半区
        for(int j = 0; j < pp1.size(); j += 2) {
            int xx = max(pp1[j], pp1[j + 1]);
            if (xx == mark) flag = true;
            pp3.push_back(xx);
        }
        pp1 = pp3;

        // 第二半区
        for(int j = 0; j < pp2.size(); j += 2) {
            int xx = max(pp2[j], pp2[j + 1]);
            if (xx == mark) flag = true;
            pp4.push_back(xx);
        }
        pp2 = pp4;

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

    int nn1 = max(pp1[0], pp1[1]);
    int nn2 = max(pp2[0], pp2[1]);

    if (nn1 != mark && nn2 != mark) {
        cout << 4 << endl;
        return;
    }

    nn1 = max(nn1, nn2);
    if (nn1 == 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: 3840kb

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: 3648kb

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

result:

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