QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#568890 | #9308. World Cup | yylx | WA | 0ms | 3792kb | C++14 | 2.4kb | 2024-09-16 19:06:02 | 2024-09-16 19:06:02 |
Judging History
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'