QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#574599#9308. World CupyylxWA 1ms3864kbC++142.4kb2024-09-18 23:10:592024-09-18 23:11:00

Judging History

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

  • [2024-09-18 23:11:00]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3864kb
  • [2024-09-18 23:10:59]
  • 提交

answer

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int simulateTournament(vector<int>& strengths) {
    // 1. Sort teams by strength (descending)
    sort(strengths.begin(), strengths.end(), greater<int>());

    // 2. Group Stage Arrangement
    vector<vector<int>> groups(8, vector<int>(4));
    groups[0] = {strengths[0], strengths[31], strengths[30], strengths[29]}; // Chinese team with weakest

    int strengthIndex = 1;
    for (int i = 1; i < 8; ++i) {
        for (int j = 0; j < 4; ++j) {
            groups[i][j] = strengths[strengthIndex++];
        }
    }

    // 3. Simulate Knockout Stage
    vector<int> roundOf16;
    for (int i = 0; i < 8; ++i) {
        // Find the top two teams in each group
        sort(groups[i].begin(), groups[i].end(), greater<int>());
        roundOf16.push_back(groups[i][0]); 
        roundOf16.push_back(groups[i][1]);
    }

    // Predefined Round of 16 matches
    vector<pair<int, int>> matches = {
        {0, 9}, {8, 1}, {2, 11}, {10, 3}, {4, 13}, {12, 5}, {6, 15}, {14, 7}
    };

    vector<int> quarterFinals;
    for (auto& match : matches) {
        quarterFinals.push_back(max(roundOf16[match.first], roundOf16[match.second]));
    }

    vector<int> semiFinals;
    for (int i = 0; i < 4; ++i) {
        semiFinals.push_back(max(quarterFinals[2 * i], quarterFinals[2 * i + 1]));
    }

    int finalist1 = max(semiFinals[0], semiFinals[1]);
    int finalist2 = max(semiFinals[2], semiFinals[3]);

    int champion = max(finalist1, finalist2);

    // 4. Determine Chinese team's result
    if (champion == strengths[0]) return 1; // Champion
    if (finalist1 == strengths[0] || finalist2 == strengths[0]) return 2; // Finalist
    if (find(semiFinals.begin(), semiFinals.end(), strengths[0]) != semiFinals.end()) return 4; // Semi-finalist
    if (find(quarterFinals.begin(), quarterFinals.end(), strengths[0]) != quarterFinals.end()) return 8; // Quarter-finalist
    if (find(roundOf16.begin(), roundOf16.end(), strengths[0]) != roundOf16.end()) return 16; // Round of 16
    return 32; // Didn't advance
}

int main() {
    int t;
    cin >> t;

    while (t--) {
        vector<int> strengths(32);
        for (int i = 0; i < 32; ++i) {
            cin >> strengths[i];
        }

        int result = simulateTournament(strengths);
        cout << result << endl;
    }

    return 0;
}

詳細信息

Test #1:

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

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

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:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

result:

wrong answer 1st numbers differ - expected: '32', found: '1'