QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#565878 | #9308. World Cup | shumian | WA | 0ms | 3608kb | C++23 | 2.1kb | 2024-09-15 22:29:28 | 2024-09-15 22:29:30 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve() {
vector<vector<int>> groups(8);
int mark;
// 输入小组赛数据
for (int i = 0; i < 8; ++i) {
vector<int> nums(4);
for (int j = 0; j < 4; ++j) {
cin >> nums[j];
if (i == 0 && j == 0) mark = nums[j]; // 记录中国队的实力
}
sort(nums.rbegin(), nums.rend());
groups[i] = nums;
}
// 确定小组前两名
vector<int> qualified;
bool chineseTeamQualified = false;
for (const auto& group : groups) {
qualified.push_back(group[0]); // 第一名
qualified.push_back(group[1]); // 第二名
if (group[0] == mark || group[1] == mark) {
chineseTeamQualified = true; // 中国队晋级
}
}
if (!chineseTeamQualified) {
cout << 32 << endl; // 中国队未晋级
return;
}
// 淘汰赛
vector<int> knockout(16);
for (int i = 0; i < 8; ++i) {
knockout[i * 2] = groups[i][0]; // 第一名
knockout[i * 2 + 1] = groups[i][1]; // 第二名
}
int round = 16;
while (round > 1) {
vector<int> nextRound;
bool markInRound = false;
for (int i = 0; i < knockout.size(); i += 2) {
int winner = max(knockout[i], knockout[i + 1]);
if (winner == mark) {
markInRound = true;
}
nextRound.push_back(winner);
}
knockout = nextRound;
if (!markInRound) {
cout << round << endl; // 输出当前轮次
return;
}
round /= 2; // 每轮减半
}
// 最后两队比较
int final1 = knockout[0];
int final2 = knockout[1];
if (final1 == mark || final2 == mark) {
cout << (final1 == mark ? 1 : 2) << endl; // 1: 决赛, 2: 亚军
} else {
cout << 4 << endl; // 半决赛
}
}
signed main() {
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
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: 3608kb
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 8 8 8 8 4 4 4 4 4 4 4 4 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1
result:
wrong answer 4th numbers differ - expected: '16', found: '8'