QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#524426 | #5043. Game | E_huan | WA | 279ms | 3916kb | C++14 | 2.1kb | 2024-08-19 17:27:13 | 2024-08-19 17:27:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef pair<int,int> pii;
#define x first
#define y second
#define pb push_back
inline int read() {
char ch=getchar();
int res=0; bool f=0;
while(!isdigit(ch)) f|=(ch=='-'),ch=getchar();
while(isdigit(ch)) res=res*10+(ch-'0'),ch=getchar();
return f?-res:res;
}
mt19937 rnd(chrono::duration_cast< chrono::nanoseconds>(chrono::system_clock::now().time_since_epoch()).count());
inline int rd(int l,int r) {
return rnd()%(r-l+1)+l;
}
const int N=25,up=24*23/2;
int a[N],b[N];
inline bool calc2() {
int i=1,j=1;
while(i<=24&&j<=24) {
if(a[i]==b[j]||(a[i]==0)||(b[j]==0)) i++,j++;
else if(a[i]==1) {
if(b[j]==2) i++;
else j++;
}
else if(b[j]==1) {
if(a[i]==2) j++;
else i++;
}
else {
if(a[i]<b[j]) i++;
else j++;
}
}
return j<=24;
}
inline int calc() {
int all=0;
for(int i=1;i<=24;i++)
for(int j=i+1;j<=24;j++) {
swap(b[i],b[j]);
all+=calc2();
swap(b[i],b[j]);
}
return all;
} // 最差情况下 bob 多 比 A 多剩几个(可以是负数)
inline void print() {
for(int i=1;i<=24;i++) printf("%d ",b[i]+30);
puts("");
}
inline bool work() {
for(int i=2;i<=24;i++) swap(b[i],b[rd(1,i-1)]);
int last=calc();
if(last==up) {print(); return 1;}
for(int t=1;t<=83;t++) {
int x=rd(1,24),y=rd(1,24);
if(x==y) continue;
swap(b[x],b[y]);
int now=calc();
if(now==up) {print(); return 1;}
if(now>last) last=now;
else swap(b[x],b[y]);
// cerr<<t<<endl;
}
return 0;
}
signed main() {
// freopen("in.in","r",stdin);
// freopen("out.out","w",stdout);
int TT=read();
while(TT--) {
for(int i=1;i<=24;i++) b[i]=a[i]=read()-30; //0-10
for(int i=1,f=0;i<=15&&(!f);i++) f|=work();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 9ms
memory: 3880kb
input:
4 40 39 38 38 37 37 36 36 35 35 34 34 34 33 33 33 32 32 32 31 31 31 30 30 34 31 36 33 31 39 37 38 35 32 32 35 36 31 34 32 38 40 30 33 30 34 33 37 37 30 40 38 36 38 32 34 36 35 37 32 34 33 31 30 33 31 35 34 33 39 31 32 30 33 32 39 37 38 35 40 34 30 31 37 31 33 31 33 34 32 36 36 35 34 32 38
output:
36 32 34 34 31 30 31 37 36 37 33 30 35 32 40 32 34 33 38 39 38 35 33 31 34 32 33 37 30 31 37 31 40 34 34 35 35 32 38 33 30 33 36 31 39 32 36 38 35 38 37 33 30 31 40 32 39 34 36 34 32 31 36 30 35 33 34 37 38 32 31 33 35 37 40 31 34 36 32 37 30 30 32 34 33 31 36 39 38 35 32 38 31 33 33 34
result:
ok AC
Test #2:
score: 0
Accepted
time: 1ms
memory: 3752kb
input:
1 31 37 34 39 36 34 38 36 31 40 30 34 37 35 33 33 38 33 31 32 30 32 32 35
output:
30 32 34 33 31 30 31 37 38 32 37 32 39 34 36 34 40 38 33 31 35 36 35 33
result:
ok AC
Test #3:
score: 0
Accepted
time: 3ms
memory: 3864kb
input:
2 36 39 34 31 36 32 33 30 31 34 38 35 33 34 37 38 32 31 40 32 30 37 33 35 38 34 34 32 40 32 37 36 30 33 36 32 31 33 39 33 35 34 31 38 31 37 35 30
output:
31 34 37 36 32 33 34 30 35 38 32 37 31 33 33 32 36 39 31 30 35 34 40 38 33 40 36 36 33 39 30 38 32 37 34 35 34 32 37 31 31 30 32 38 35 31 34 33
result:
ok AC
Test #4:
score: 0
Accepted
time: 183ms
memory: 3884kb
input:
100 33 30 34 34 32 31 39 33 36 35 38 31 37 37 33 36 35 31 32 38 40 30 32 34 35 38 33 30 40 30 35 39 31 38 37 33 37 31 34 34 32 36 33 32 36 32 34 31 31 30 36 31 40 33 33 30 38 32 34 38 39 34 37 35 33 36 35 34 32 32 37 31 30 40 36 35 37 36 33 31 35 34 33 34 31 33 30 32 38 39 32 37 38 34 32 31 34 34 31...
output:
34 35 33 37 31 40 38 30 39 38 32 35 34 37 32 31 30 31 36 36 34 32 33 33 34 31 30 37 38 33 33 40 34 34 35 32 35 31 33 36 36 32 39 31 38 30 37 32 32 31 37 36 34 33 31 30 38 39 33 35 32 33 37 31 35 34 36 40 38 32 30 34 37 32 34 35 38 34 33 31 38 30 33 34 31 36 37 31 39 40 33 35 32 32 30 36 33 35 37...
result:
ok AC
Test #5:
score: -100
Wrong Answer
time: 279ms
memory: 3916kb
input:
100 33 31 30 31 31 37 36 39 34 33 34 38 38 32 34 40 37 32 33 35 35 36 30 32 33 36 32 34 30 31 32 32 33 40 30 33 39 37 35 38 35 36 38 31 34 37 34 31 30 33 32 32 33 33 37 34 36 36 31 37 38 35 38 31 35 34 40 31 30 32 39 34 32 31 38 34 33 37 33 30 31 33 35 34 37 40 39 30 31 38 35 32 36 36 34 32 37 32 31...
output:
31 33 36 32 36 32 31 32 38 34 40 35 33 30 33 30 38 35 37 31 34 34 39 37 37 32 35 39 32 30 33 38 38 31 34 31 33 36 34 31 34 37 33 40 36 35 30 32 37 38 32 34 40 32 30 39 35 30 33 37 35 32 31 33 38 31 36 34 36 31 33 34 36 32 37 34 36 31 39 38 34 34 32 40 32 31 35 30 33 30 33 33 31 38 35 37 36 38 35...
result:
wrong answer Bob can't win in at least one cases.