Download 2022/round3/fourth_player.cpp from hackercupai/hackercup: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/datasets/hackercupai/hackercup/resolve/main/2022/round3/fourth_player.cpp
- Command line
-
hf download hf://datasets/hackercupai/hackercup/2022/round3/fourth_player.cpp
-
curl -L -o fourth_player.cpp https://huggingface.co/datasets/hackercupai/hackercup/resolve/main/2022/round3/fourth_player.cpp
1.32 kB
| using namespace std; | |
| int solve() { | |
| int N; | |
| cin >> N; | |
| vector<vector<int>> C(2); | |
| for (int i = 0; i < 4; i++) { | |
| vector<int> H(N/4); | |
| for (int j = 0; j < N/4; j++) { | |
| cin >> H[j]; | |
| } | |
| sort(H.begin(), H.end()); | |
| if (i == 0) { | |
| C[0] = H; | |
| } else { | |
| int us = i % 2, them = 1 - us; | |
| vector<vector<int>> C2(2); | |
| // Cover as many of their team's highest cards as possible. | |
| for_each(C[them].rbegin(), C[them].rend(), [&](int card) { | |
| if (!H.empty() && H.back() > card) { | |
| C2[us].push_back(H.back()); | |
| H.pop_back(); | |
| } else { | |
| C2[them].push_back(card); | |
| } | |
| }); | |
| // Cover as many of our team's lowest cards as possible. | |
| for (int card : C[us]) { | |
| if (!H.empty() && H.back() >= card) { | |
| C2[us].push_back(H.back()); | |
| H.pop_back(); | |
| } else { | |
| C2[us].push_back(card); | |
| } | |
| } | |
| C = C2; | |
| sort(C[us].begin(), C[us].end()); | |
| sort(C[them].begin(), C[them].end()); | |
| } | |
| } | |
| return C[0].size(); | |
| } | |
| int main() { | |
| ios_base::sync_with_stdio(false); | |
| cin.tie(nullptr); | |
| int T; | |
| cin >> T; | |
| for (int t = 1; t <= T; t++) { | |
| cout << "Case #" << t << ": " << solve() << endl; | |
| } | |
| return 0; | |
| } | |