QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#565936 | #9308. World Cup | chhh31 | WA | 1ms | 3612kb | C++17 | 2.5kb | 2024-09-15 22:40:32 | 2024-09-15 22:40:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
void solve()
{
vector<vector<int>> q, q2, q3;
int mark;
for (int i = 0; i < 8; i++)
{
vector<int> num;
for (int j = 0; j < 4; j++)
{
int x;
cin >> x;
if (i == 0 && j == 0) mark = x;
num.push_back(x);
}
sort(num.rbegin(), num.rend());
q.push_back(num);
}
int len = q.size();
for (int i = 0; i < len; i++) // 32 -> 16;
{
while (q[i].size() > 2) q[i].pop_back();
}
vector<int> qq;
bool flag = false;
for (int i = 0; i < q.size(); i++)
{
for (int j = 0; j < q[i].size(); j++)
{
qq.push_back(q[i][j]);
if (q[i][j] == mark) flag = true;
}
}
if (!flag)
{
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++)
{
int flag = 0;
vector<int> pp3, pp4;
for (int j = 0; j < pp1.size(); j += 2)
{
int xx = max(pp1[j], pp1[j + 1]);
pp3.push_back(xx);
}
pp1 = pp3;
pp3.clear();
// 使用 std::find 查找 mark
if (find(pp1.begin(), pp1.end(), mark) != pp1.end())
{
flag = 1;
}
for (int j = 0; j < pp2.size(); j += 2)
{
int xx = max(pp2[j], pp2[j + 1]);
pp4.push_back(xx);
}
pp2 = pp4;
// 使用 std::find 查找 mark
if (find(pp2.begin(), pp2.end(), mark) != pp2.end()) flag = 1;
pp4.clear();
if (!flag)
{
cout << round << endl;
return;
}
round /= 2;
}
int nn1 = pp1[0], nn2 = pp1[1], nn3 = pp2[0], nn4 = pp2[1];
nn1 = max(nn1, nn2), nn3 = max(nn3, nn4);
if (nn1 != mark && nn3 != mark)
{
cout << 4 << endl;
return;
}
nn1 = max(nn1, nn3);
if (nn1 == mark)
{
cout << 1 << endl;
}
else
{
cout << 2 << endl;
}
}
int 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: 3592kb
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: 3612kb
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'