QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#71365 | #5260. The Game | Sorting# | RE | 0ms | 0kb | C++ | 1.4kb | 2023-01-09 20:51:52 | 2023-01-09 20:51:54 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
int m=98;
int p[99];
int h[13];
vector<int>st[5];
int score(int card,int row){
if(card==0) return 1000;
bool dir=(st[row][0]!=1)^(st[row].back()<card);
if(!dir){
if(abs(st[row].back()-card)==10) return -1;
else return 1000;
}
else return abs(st[row].back()-card);
}
bool play(){
vector<pair<int,pair<int,int> > >v;
for(int i=1; i<=8 ;i++){
for(int j=1; j<=4 ;j++){
int sco=score(h[i],j);
v.push_back({sco,{i,j}});
}
}
sort(v.begin(),v.end());
if(v[0].fi==1000) return false;
st[v[0].se.se].push_back(h[v[0].se.fi]);
h[v[0].se.fi]=0;
}
int ptr=8;
void out(){
for(int i=1; i<=4 ;i++){
for(auto c:st[i]) cout << c << ' ';
cout << '\n';
}
for(int i=1; i<=8 ;i++) if(h[i]>0) cout << h[i] << ' ';
cout << '\n';
for(int i=ptr+1; i<=m ;i++) cout << p[i] << ' ';
cout << '\n';
exit(0);
}
int main(){
ios::sync_with_stdio(false);cin.tie(0);
for(int i=1; i<=m ;i++) cin >> p[i];
st[1].push_back(1);
st[2].push_back(1);
st[3].push_back(100);
st[4].push_back(100);
for(int i=1; i<=ptr ;i++){
h[i]=p[i];
}
while(ptr<m){
if(!play()) out();
if(!play()) out();
h[9]=p[++ptr];
h[10]=p[++ptr];
for(int i=1; i<=9 ;i++){
if(h[i]==0) swap(h[i],h[i+1]);
}
for(int i=1; i<=9 ;i++){
if(h[i]==0) swap(h[i],h[i+1]);
}
}
while(true){
if(!play()) out();
}
out();
}
詳細信息
Test #1:
score: 0
Dangerous Syscalls
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