QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#524424#5043. GameE_huanWA 181ms4012kbC++142.0kb2024-08-19 17:25:562024-08-19 17:25:57

Judging History

你现在查看的是最新测评结果

  • [2024-08-19 17:25:57]
  • 评测
  • 测评结果:WA
  • 用时:181ms
  • 内存:4012kb
  • [2024-08-19 17:25:56]
  • 提交

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(time(0)^clock());
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<=133;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<=10&&(!f);i++) f|=work();
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 4ms
memory: 3888kb

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:

38 34 36 35 31 30 32 34 31 31 38 32 35 37 40 32 33 39 34 37 30 33 33 36 
34 32 38 34 32 30 36 31 39 34 31 33 40 38 30 35 35 31 36 37 32 37 33 33 
34 39 30 33 37 30 31 38 38 31 34 35 34 32 40 32 35 32 31 36 33 36 37 33 
34 40 39 31 30 35 35 30 37 32 37 32 36 31 38 32 31 33 34 33 34 36 33 38 

result:

ok AC

Test #2:

score: 0
Accepted
time: 0ms
memory: 3888kb

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:

36 34 30 33 34 39 31 37 35 31 40 32 38 38 31 36 32 35 33 32 33 34 30 37 

result:

ok AC

Test #3:

score: 0
Accepted
time: 4ms
memory: 4012kb

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:

39 36 30 37 34 31 37 33 34 32 31 38 31 40 36 32 33 35 30 34 35 32 33 38 
36 33 39 35 31 33 38 35 30 34 37 36 33 32 37 30 31 31 34 32 38 32 40 34 

result:

ok AC

Test #4:

score: 0
Accepted
time: 142ms
memory: 3844kb

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:

38 34 33 37 36 32 34 35 32 33 31 35 31 34 30 37 39 30 38 32 33 31 40 36 
33 33 33 38 31 30 32 38 40 34 32 39 35 32 31 36 37 36 34 31 34 37 30 35 
30 34 39 32 31 30 38 32 33 38 35 31 33 34 37 40 33 37 36 32 35 31 34 36 
31 31 33 38 34 37 34 35 32 35 31 33 34 36 33 39 32 37 40 30 36 30 32 38 
37 32 31...

result:

ok AC

Test #5:

score: 0
Accepted
time: 179ms
memory: 3820kb

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:

35 34 37 38 34 33 32 32 36 30 37 30 35 34 36 33 40 31 39 31 32 31 38 33 
35 35 34 38 34 32 36 32 33 31 33 38 30 40 37 39 33 32 37 34 31 31 36 30 
30 38 37 30 31 39 32 36 33 32 34 34 34 37 31 33 32 36 31 35 40 33 38 35 
34 38 33 37 36 34 32 36 33 32 39 31 34 31 37 31 30 35 40 35 33 32 30 38 
33 33 34...

result:

ok AC

Test #6:

score: -100
Wrong Answer
time: 181ms
memory: 3840kb

input:

100
32 38 31 36 34 31 37 35 35 39 33 32 40 37 32 31 34 38 33 36 30 33 34 30
33 33 31 37 30 38 36 35 40 32 37 39 35 33 30 32 34 32 31 31 34 38 36 34
33 38 32 36 39 37 35 34 33 31 38 32 35 36 31 30 32 37 33 34 34 30 31 40
36 32 34 36 31 33 32 37 38 39 34 32 30 37 35 31 33 31 40 38 33 30 35 34
33 32 30...

output:

33 38 32 31 31 39 33 36 30 36 38 30 34 37 33 32 31 34 32 35 35 40 37 34 
34 37 37 32 31 39 31 40 34 35 31 38 32 33 34 38 33 32 36 30 30 36 35 33 
38 36 31 37 33 38 33 31 40 34 32 37 30 39 35 32 34 35 30 36 33 32 31 34 
37 32 35 36 34 32 37 34 31 40 36 39 30 33 32 31 35 30 34 38 33 33 31 38 
34 33 38...

result:

wrong answer Bob can't win in at least one cases.