QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#89303 | #5260. The Game | sky3142# | WA | 2ms | 3528kb | C++20 | 3.2kb | 2023-03-19 17:05:45 | 2023-03-19 17:05:48 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
vector<int> cards, hand, up1, up2, down1, down2;
int top = 8;
int trick()
{
for(int i=0;i<hand.size();i++)
{
if(hand[i] < up1.back() && hand[i]+10==up1.back())
{
up1.push_back(hand[i]);
hand.erase(hand.begin()+i);
return 1;
}
if(hand[i] < up2.back() && hand[i]+10==up2.back())
{
up2.push_back(hand[i]);
hand.erase(hand.begin()+i);
return 1;
}
if(hand[i] > down1.back() && hand[i]-10==down1.back())
{
down1.push_back(hand[i]);
hand.erase(hand.begin()+i);
return 1;
}
if(hand[i] > down2.back() && hand[i]-10==down2.back())
{
down2.push_back(hand[i]);
hand.erase(hand.begin()+i);
return 1;
}
}
return 0;
}
int reg()
{
int minv = 100, k = -1, w = -1;
for(int i=0;i<hand.size();i++)
{
if(hand[i] > up1.back() && hand[i] - up1.back() < minv)
{
minv = hand[i] - up1.back();
k = i;
w= 1;
}
if(hand[i] > up2.back() && hand[i] - up2.back() < minv)
{
minv = hand[i] - up2.back();
k = i;
w=2;
}
if(hand[i] <down1.back() && down1.back()-hand[i] < minv)
{
minv = down1.back()-hand[i];
k = i;
w=3;
}
if(hand[i] <down2.back() && down2.back()-hand[i] < minv)
{
minv = down2.back()-hand[i];
k = i;
w=4;
}
}
if(k==-1) return 0;
if(w == 1) up1.push_back(hand[k]);
if(w == 2) up2.push_back(hand[k]);
if(w == 3) down1.push_back(hand[k]);
if(w == 4) down2.push_back(hand[k]);
hand.erase(hand.begin()+k);
return 1;
}
void end()
{
for(int i : up1) cout << i << ' ';
cout << '\n';
for(int i : up2) cout << i << ' ';
cout << '\n';
for(int i : down1) cout << i << ' ';
cout << '\n';
for(int i : down2) cout << i << ' ';
cout << '\n';
for(int i : hand) cout << i << ' ';
cout << '\n';
for(int i=top;i<98;i++) cout << cards[i] << ' ';
cout << '\n';
}
void next_round()
{
if(top < 98) hand.push_back(cards[top++]);
if(top < 98) hand.push_back(cards[top++]);
}
int f()
{
int t = trick();
if(!t) return reg();
return t;
}
void solve()
{
for(int i=0;i<98;i++)
{
int x;
cin >> x;
cards.push_back(x);
}
up1.push_back(1), up2.push_back(1), down1.push_back(100), down2.push_back(100);
for(int i=0;i<8;i++) hand.push_back(cards[i]);
while(hand.size())
{
if(f()+f() < 2)
{
end();
return ;
}
next_round();
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
}
详细
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3528kb
input:
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
output:
result:
wrong answer 1st lines differ - expected: '1 2 3 4 5 6 7 8 9 10 11 12 13 ...9 90 91 92 93 94 95 96 97 98 99', found: ''