QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#524283#5043. GameCelebrateTL 94ms3692kbC++141.4kb2024-08-19 15:03:402024-08-19 15:03:40

Judging History

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

  • [2024-08-19 15:03:40]
  • 评测
  • 测评结果:TL
  • 用时:94ms
  • 内存:3692kb
  • [2024-08-19 15:03:40]
  • 提交

answer

#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<=y;i++)
#define dwn(i,x,y) for(int i=x;i>=y;i--)
#define ll long long
using namespace std;
template<typename T>inline void qr(T &x){
    x=0;int f=0;char s=getchar();
    while(!isdigit(s))f|=s=='-',s=getchar();
    while(isdigit(s))x=x*10+s-48,s=getchar();
    x=f?-x:x;
}
int cc=0,buf[31];
template<typename T>inline void qw(T x){
    if(x<0)putchar('-'),x=-x;
    do{buf[++cc]=int(x%10);x/=10;}while(x);
    while(cc)putchar(buf[cc--]+'0');
}
const int N=31;
int a[N],b[N];
int bijiao(){
    int i=1,j=1;
    while(i<=24&&j<=24){
        if(a[i]==b[j]||a[i]==30||b[j]==30)i++,j++;
        else if(a[i]==31&&b[j]==32)i++;
        else if(b[j]==31&&a[i]==32)j++;
        else if(a[i]==31&&b[j]>=33)j++;
        else if(b[j]==31&&a[i]>=33)i++;
        else if(a[i]>b[j])j++;
        else i++;
    }
    return i==25&&j<=24;
}
int calc(){
    int ans=0;
    rep(i,1,23)rep(j,i+1,24){
        swap(b[i],b[j]);
        ans+=bijiao();
        swap(b[i],b[j]);
    }
    return ans;
}
void solve(){
    rep(i,1,24)qr(a[i]);
    rep(i,1,24)b[i]=a[i];
    int cnt=calc();
    random_device rd;
    mt19937 g(rd());
    while(cnt<23*12){
        shuffle(b+1,b+25,g);
        cnt=calc();
    }
    rep(i,1,24)qw(b[i]),putchar(' ');
    puts("");
}
int main(){
    srand(time(0));
    int tt;qr(tt);
    while(tt--)solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 94ms
memory: 3692kb

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:

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

result:

ok AC

Test #2:

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

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:

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

result:

ok AC

Test #3:

score: 0
Accepted
time: 55ms
memory: 3596kb

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:

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

result:

ok AC

Test #4:

score: -100
Time Limit Exceeded

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:

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

result: