QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#424929#5954. Power Swappersunrise20480 37ms3832kbC++141.9kb2024-05-29 19:57:492024-05-29 19:57:50

Judging History

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

  • [2024-05-29 19:57:50]
  • 评测
  • 测评结果:0
  • 用时:37ms
  • 内存:3832kb
  • [2024-05-29 19:57:49]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=12;
int T;
int n;
ll jc[N+5];
ll ans;
vector<int> a;
void dfs(vector<int> a,int len){
    if(a.size()==1){
        ans+=jc[len];
        return;
    }
    vector<int> f;
    for(int i=0;i<a.size();i+=2){
        if(a[i]+1!=a[i+1]||a[i]%2==1){
            f.push_back(a[i]);
        }
    }
    vector<int> b,c;
    if(f.size()<=1){
        for(int i=0;i<a.size();i+=2){
            b.push_back(a[i]/2);
        }
        dfs(b,len+f.size());
        return;
    }
    if(f.size()>2)return;
    if(a[f[0]]==a[f[0]+1]+1&&a[f[0]]%2==1)return;
    c=a;
    if(a[f[0]]+1==a[f[1]+1]&&a[f[1]]+1==a[f[0]+1]){
        b.clear();
        swap(a[f[0]],a[f[1]]);
        for(int i=0;i<a.size();i+=2){
            b.push_back(a[i]/2);
        }
        dfs(b,len+1);
    }
    a=c;
    if(a[f[0]+1]+1==a[f[1]+1]&&a[f[0]]+1==a[f[1]]){
        b.clear();
        swap(a[f[0]+1],a[f[1]]);
        for(int i=0;i<a.size();i+=2){
            b.push_back(a[i]/2);
        }
        dfs(b,len+1);
    }
    a=c;
    if(a[f[0]]==a[f[1]]+1&&a[f[0]+1]+1==a[f[1]+1]){
        b.clear();
        swap(a[f[0]],a[f[1]+1]);
        for(int i=0;i<a.size();i+=2){
            b.push_back(a[i]/2);
        }
        dfs(b,len+1);
    }
    a=c;
    if(a[f[0]+1]==a[f[1]]+1&&a[f[1]+1]==a[f[0]]+1){
        b.clear();
        swap(a[f[0]+1],a[f[1]+1]);
        for(int i=0;i<a.size();i+=2){
            b.push_back(a[i]/2);
        }
        dfs(b,len+1);
    }
}
int main(){
    jc[0]=1;
    for(int i=1;i<=N;++i)jc[i]=jc[i-1]*i;
    cin>>T;
    for(int TT=1;TT<=T;++TT){
        cin>>n;
        a.clear();
        ans=0;
        for(int i=0;i<(1<<n);++i){
            int ls;
            cin>>ls;
            --ls;
            a.push_back(ls);
        }
        dfs(a,0);
        printf("Case #%d: %lld\n",TT,ans);
    }
    return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3672kb

input:

200
1
2 1
2
1 4 3 2
3
7 8 5 6 1 2 4 3
2
4 3 2 1
2
2 4 1 3
4
3 10 11 12 1 2 9 4 13 14 15 16 5 6 7 8
1
2 1
1
2 1
1
2 1
1
1 2
4
1 2 3 4 13 14 15 16 9 12 11 10 5 6 7 8
4
9 10 11 12 1 2 15 16 13 14 6 4 5 3 7 8
2
1 4 3 2
2
3 2 1 4
4
1 2 3 4 13 14 15 16 9 10 11 8 5 6 7 12
4
13 14 11 12 1 2 5 4 9 10 15 16 3...

output:

Case #1: 1
Case #2: 3
Case #3: 6
Case #4: 0
Case #5: 0
Case #6: 0
Case #7: 1
Case #8: 1
Case #9: 1
Case #10: 1
Case #11: 38
Case #12: 0
Case #13: 3
Case #14: 3
Case #15: 0
Case #16: 0
Case #17: 8
Case #18: 0
Case #19: 3
Case #20: 0
Case #21: 1
Case #22: 24
Case #23: 0
Case #24: 0
Case #25: 0
Case #2...

result:

wrong answer 5th lines differ - expected: 'Case #5: 2', found: 'Case #5: 0'

Subtask #2:

score: 0
Wrong Answer

Test #2:

score: 0
Wrong Answer
time: 37ms
memory: 3832kb

input:

200
1
2 1
2
1 4 3 2
3
7 8 5 6 1 2 4 3
2
4 3 2 1
6
33 34 35 36 37 38 39 40 41 42 43 44 19 20 51 52 47 10 11 12 13 14 15 16 57 58 59 60 61 62 63 64 1 2 3 4 5 6 7 8 45 46 9 48 53 54 55 56 17 18 49 50 21 22 23 24 25 26 27 28 29 30 31 32
10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 2...

output:

Case #1: 1
Case #2: 3
Case #3: 6
Case #4: 0
Case #5: 0
Case #6: 1
Case #7: 0
Case #8: 2
Case #9: 0
Case #10: 0
Case #11: 0
Case #12: 0
Case #13: 0
Case #14: 0
Case #15: 0
Case #16: 0
Case #17: 0
Case #18: 0
Case #19: 1
Case #20: 1
Case #21: 1
Case #22: 0
Case #23: 0
Case #24: 0
Case #25: 0
Case #26:...

result:

wrong answer 5th lines differ - expected: 'Case #5: 120', found: 'Case #5: 0'