QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#507290 | #5252. Deforestation | ucup-team1525# | WA | 0ms | 3772kb | C++17 | 3.5kb | 2024-08-06 15:22:41 | 2024-08-06 15:22:41 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
vector<int> vec[4];
vector<int> draws;
deque<int> inhand;
int main() {
for (int i = 1; i <= 98; i++) {
int x;
scanf("%d", &x);
draws.push_back(x);
}
reverse(draws.begin(), draws.end());
vec[0].push_back(1), vec[1].push_back(1), vec[2].push_back(100), vec[3].push_back(100);
for (int i = 1; i <= 8; i++) {
int x = draws.back();
inhand.push_back(x);
draws.pop_back();
}
while (!draws.empty() || !inhand.empty()) {
bool is_nol = false;
for (int i = 0; i < 2; i++) {
if (inhand.empty())
break;
bool put_card = false;
// check backward
for (auto it = inhand.begin(); it != inhand.end(); it = next(it)) {
int card = *it;
bool flag = 0;
for (int j = 0; j < 4; j++) {
if (j < 2 && vec[j].back() - card == 10) {
vec[j].push_back(card);
flag = true;
inhand.erase(it);
put_card = true;
break;
} else if (j >= 2 && card - vec[j].back() == 10) {
vec[j].push_back(card);
flag = true;
inhand.erase(it);
put_card = true;
break;
}
if (flag)
break;
}
if (flag)
break;
}
if (put_card)
continue;
// min abs
int mnabs = 1e9, mnj = 0;
auto select = inhand.begin();
for (auto it = inhand.begin(); it != inhand.end(); it = next(it)) {
int card = *it;
bool flag = 0;
for (int j = 0; j < 4; j++) {
if (j < 2 && vec[j].back() < card) {
if (mnabs > card - vec[j].back())
mnabs = card - vec[j].back(), mnj = j, select = it;
else if (mnabs == card - vec[j].back() && mnj > j)
mnj = j, select = it;
} else if (j >= 2 && vec[j].back() > card) {
if (mnabs > vec[j].back() - card)
mnabs = vec[j].back() - card, mnj = j, select = it;
else if (mnabs == vec[j].back() - card && mnj > j)
mnj = j, select = it;
}
}
}
if (mnabs < 1e9) {
int card = *select;
vec[mnj].push_back(card);
inhand.erase(select);
printf("putcard: %d %d %d\n", mnabs , mnj, card);
} else {
is_nol = true;
break;
}
}
if (is_nol) break;
// draw 2 cards
int cnt = 2;
while (cnt-- && !draws.empty())
inhand.push_back(draws.back()), draws.pop_back();
}
for (int i = 0; i < 4; i++)
for (int j = 0; j < vec[i].size(); j++)
printf("%d%c", vec[i][j], " \n"[j + 1 == (int)vec[i].size()]);
for (auto i : inhand) cout << i << " ";
cout << "\n";
for (auto i : draws) cout << i << " ";
cout << "\n";
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3772kb
input:
999900000 7339 3 14947 2 12850 3 8986 10 11599 9 8889 10 10711 4 8015 1 11626 0 9492 1 7017 0 8863 0 8632 0 5321 5 9906 0 11687 0 9845 0 10469 0 11708 0 14950 5 11934 0 11922 0 13101 0 12000 0 9082 0 9273 5 12296 0 6119 0 9201 0 12652 0 12957 0 7454 5 12515 0 12976 0 10358 0 13997 0 8371 0 10181 5 8...
output:
putcard: 1 0 2 putcard: 1 0 3 putcard: 2 1 3 putcard: 7 0 10 putcard: 6 1 9 putcard: 7329 0 7339 putcard: 1 1 10 putcard: 1550 0 8889 putcard: 96 2 4 putcard: 97 0 8986 putcard: 3 2 1 putcard: 1725 0 10711 putcard: 888 0 11599 putcard: 1 1 1 putcard: 27 0 11626 putcard: 1 2 0 putcard: 1224 0 12850 p...
result:
wrong answer 1st lines differ - expected: '1', found: 'putcard: 1 0 2'