QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#524425#5043. GameE_huanWA 226ms3908kbC++142.1kb2024-08-19 17:26:522024-08-19 17:26:53

Judging History

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

  • [2024-08-19 17:26:53]
  • 评测
  • 测评结果:WA
  • 用时:226ms
  • 内存:3908kb
  • [2024-08-19 17:26:52]
  • 提交

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<=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: 7ms
memory: 3904kb

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:

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

result:

ok AC

Test #2:

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

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 35 37 31 36 31 32 38 30 34 35 39 37 33 32 34 33 32 34 36 38 31 33 40 

result:

ok AC

Test #3:

score: 0
Accepted
time: 12ms
memory: 3908kb

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:

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

result:

ok AC

Test #4:

score: 0
Accepted
time: 131ms
memory: 3776kb

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:

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

result:

ok AC

Test #5:

score: 0
Accepted
time: 213ms
memory: 3908kb

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:

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

result:

ok AC

Test #6:

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

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 31 31 39 34 36 33 35 32 40 37 33 30 30 38 37 32 34 32 34 31 35 36 
31 34 32 33 34 38 33 33 31 39 34 31 37 30 37 40 35 32 32 35 38 30 36 36 
38 38 35 31 36 30 33 34 33 31 37 36 32 37 35 40 32 34 39 32 33 30 31 34 
34 38 31 36 30 39 37 32 37 35 31 33 38 32 33 35 34 32 31 30 40 36 33 34 
32 35 33...

result:

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