QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#524418#5043. GameE_huanWA 234ms3868kbC++142.0kb2024-08-19 17:23:322024-08-19 17:23:32

Judging History

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

  • [2024-08-19 17:23:32]
  • 评测
  • 测评结果:WA
  • 用时:234ms
  • 内存:3868kb
  • [2024-08-19 17:23:32]
  • 提交

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(666);
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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 5ms
memory: 3848kb

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:

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

result:

ok AC

Test #2:

score: 0
Accepted
time: 1ms
memory: 3840kb

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:

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

result:

ok AC

Test #3:

score: 0
Accepted
time: 6ms
memory: 3856kb

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:

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

result:

ok AC

Test #4:

score: 0
Accepted
time: 117ms
memory: 3868kb

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:

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

result:

ok AC

Test #5:

score: -100
Wrong Answer
time: 234ms
memory: 3844kb

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:

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

result:

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