QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#568890#9308. World CupyylxWA 0ms3792kbC++142.4kb2024-09-16 19:06:022024-09-16 19:06:02

Judging History

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

  • [2024-09-16 19:06:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3792kb
  • [2024-09-16 19:06:02]
  • 提交

answer

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

using namespace std;

// Function to simulate the round robin and knockout stages
int simulate(const vector<int>& teams) {
    vector<vector<int>> groups(8, vector<int>(4));
    
    // Divide into groups (8 groups of 4 teams)
    for (int i = 0; i < 32; ++i) {
        groups[i / 4][i % 4] = teams[i];
    }

    // Determine top 2 teams from each group based on strength
    vector<int> firstPlaces, secondPlaces;
    for (int i = 0; i < 8; ++i) {
        sort(groups[i].rbegin(), groups[i].rend());  // Sort group teams in descending order
        firstPlaces.push_back(groups[i][0]);
        secondPlaces.push_back(groups[i][1]);
    }

    // Round of 16 pairings
    vector<int> roundOf16Winners;
    for (int i = 0; i < 8; ++i) {
        if (firstPlaces[i] > secondPlaces[7 - i]) {
            roundOf16Winners.push_back(firstPlaces[i]);
        } else {
            roundOf16Winners.push_back(secondPlaces[7 - i]);
        }
    }

    // Quarter-finals pairings
    vector<int> quarterFinalWinners;
    for (int i = 0; i < 4; ++i) {
        if (roundOf16Winners[2 * i] > roundOf16Winners[2 * i + 1]) {
            quarterFinalWinners.push_back(roundOf16Winners[2 * i]);
        } else {
            quarterFinalWinners.push_back(roundOf16Winners[2 * i + 1]);
        }
    }

    // Semi-finals pairings
    vector<int> semiFinalWinners;
    for (int i = 0; i < 2; ++i) {
        if (quarterFinalWinners[2 * i] > quarterFinalWinners[2 * i + 1]) {
            semiFinalWinners.push_back(quarterFinalWinners[2 * i]);
        } else {
            semiFinalWinners.push_back(quarterFinalWinners[2 * i + 1]);
        }
    }

    // Final pairing
    if (semiFinalWinners[0] > semiFinalWinners[1]) {
        return semiFinalWinners[0] == 1 ? 1 : 2;
    } else {
        return semiFinalWinners[1] == 1 ? 1 : 2;
    }
}

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

        // We want to manipulate the grouping, so sort the teams to have the Chinese team (1) in the best position
        sort(teams.begin(), teams.end());

        // Find the result of the simulation
        int result = simulate(teams);

        cout << result << endl;
    }

    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3792kb

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:

2

result:

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