QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#150669#4327. Šeširipenguinman0 978ms26352kbC++172.1kb2023-08-25 23:54:562023-08-25 23:54:58

Judging History

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

  • [2023-08-25 23:54:58]
  • 评测
  • 测评结果:0
  • 用时:978ms
  • 内存:26352kb
  • [2023-08-25 23:54:56]
  • 提交

answer

#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::string;
using ll = int;
using vi = vector<ll>;
using vii = vector<vi>;
using pii = std::pair<ll,ll>;

#define rep(i,j,k) for(ll i=ll(j); i<ll(k); i++)
#define REP(i,j,k) for(ll i=ll(j); i<=ll(k); i++)
#define per(i,j,k) for(ll i=ll(j); i>=ll(k); i--)
#define ln "\n"
#define pb emplace_back
#define mp std::make_pair
#define mtp std::make_tuple
#define all(a) a.begin(),a.end()

vii edge, weight;
vector<bool> visited, used;
vector<string> ans;
ll N;
vi mem;

void dfs(ll now){
    visited[now] = true;
    rep(i,0,edge[now].size()){
        ll next = edge[now][i];
        ll m = weight[now][i];
        if(used[m]) continue;
        used[m] = true;
        dfs(next);
        if(now == (2<<N) || next == (2<<N)) continue;
        ll l = now/2, r = next/2;
        ll idx = N-1-mem[l^r];
        ll bit = (l&((1<<(idx))-1))+(l>>(idx+1)<<idx);
        if(now%2){
            ans[idx][bit] = 'B';
        }
        else{
            ans[idx][bit] = 'C';
        }
    }
};

int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    cin >> N;
    mem.resize(1<<N);
    rep(i,0,N) mem[1<<i] = i;
    edge.resize((2<<N)+1), weight.resize((2<<N)+1);
    ll M = 0;
    rep(i,0,1<<N){
        rep(j,0,N){
            if(i & (1<<j)){
                ll now = i;
                ll next = i^(1<<j);
                edge[now*2].pb(next*2+1);
                weight[now*2].pb(M);
                edge[next*2+1].pb(now*2);
                weight[next*2+1].pb(M);
                M++;
            }
        }
    }
    rep(i,0,2<<N){
        if(edge[i].size()%2){
            edge[i].pb((2<<N));
            weight[i].pb(M);
            edge[(2<<N)].pb(i);
            weight[(2<<N)].pb(M);
            M++;
        }
    }
    ans.resize(N, string(1<<(N-1),'A'));
    used.resize(M);
    visited.resize((2<<N)+1);

    REP(i,0,2<<N){
        if(visited[i]) continue;
        dfs(i);
    }
    rep(i,0,N){
        cout << ans[i] << ln;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

4

output:

BABBCCAA
BBACBBCC
ABCCBBCC
BCACBAAC

result:

wrong answer Token "BABBCCAA" doesn't correspond to pattern "[BC]*"

Subtask #2:

score: 0
Wrong Answer

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 3412kb

input:

5

output:

ABBBBBBBCACCAACA
BBBBCCACABBBCCCA
CCBBCCBCBCBBCCBB
BBAAABCABBCAAACC
BAACBABCACACBAAC

result:

wrong answer Token "ABBBBBBBCACCAACA" doesn't correspond to pattern "[BC]*"

Subtask #3:

score: 0
Wrong Answer

Test #3:

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

input:

6

output:

BBBBABAABBBBBBBBCCAACACCAAACAAAA
BAAABBBBACCCCAACBAAABBBBCCCCCAAC
BBBBCACCABABCCCCBBBBAACCABABCCCC
BABBCCACBABBCCACAABBCCACBABBCCAC
ABCAAACCBBAAABCCBBCAAACCBBAAABCC
BCACBAACACACBAACBAACBABAACACBAAC

result:

wrong answer Token "BBBBABAABBBBBBBBCCAACACCAAACAAAA" doesn't correspond to pattern "[BC]*"

Subtask #4:

score: 0
Wrong Answer

Test #4:

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

input:

7

output:

ABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCACCAACACCCCCCACAAAAAACAACACCACA
BBBBAAABBBBBBBBBCCCCCCCCACCCACCAABBBABBABBBBBBBBCCCCCCCCACCAACCA
ABBBBBBBCCACACAAAABABABBCCCCACCCBBBBBBBBCCACCACABABABBBBCCCCCCCA
BBCCBCBBCBCCBBCBBBCBBCBBCCBCCBCBCBCCBBCBCBCCBCBCBBCCCBBBBCCCCBCB
BABBCCAAAABBCCACBABBCCACBABACCACBABBACAA...

result:

wrong answer Token "ABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCACCAACACCCCCCACAAAAAACAACACCACA" doesn't correspond to pattern "[BC]*"

Subtask #5:

score: 0
Wrong Answer

Test #5:

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

input:

8

output:

BBBBBBBBBBBBBBBBABAABABBAAABAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCAACACCAAAAAAAACCCCACAACCCCCCCCAAAAAAAAAAAACACCAAAAAAACAAAAAAAA
BAAABBBAAAAAAAAABBBBBBBBBBBBBBBBACCCCCCCCCCCCCCCCAAACACCACCCAAACBAAABBBAAAAAAAAABBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCAAACACCACCCAAAC
BBBBABBABBBBBBBBCACACCCCAAACAAAAAAAAAAAABB...

result:

wrong answer Token "BBBBBBBBBBBBBBBBABAABABBAAABAA...AAAAAAAAAAACACCAAAAAAACAAAAAAAA" doesn't correspond to pattern "[BC]*"

Subtask #6:

score: 0
Wrong Answer

Test #6:

score: 0
Wrong Answer
time: 0ms
memory: 3712kb

input:

9

output:

ABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCACCAACACCCCAACCAAAACCAACACCAACACCCCAACCCCCCCCCCCCCCCCACAAAACCACAAAACCAAAAAAAAAAAAAAAACACCCCAACAACCAACACAAAACCACCCCCAACAACACCACA
BBBBAAABBBBBAABBAAAABBAAABBBAAABBBBBBABBBBB...

result:

wrong answer Token "ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB...CCAACACAAAACCACCCCCAACAACACCACA" doesn't correspond to pattern "[BC]*"

Subtask #7:

score: 0
Wrong Answer

Test #7:

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

input:

10

output:

BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBABAABABBAAAAAAAABBBBABAABBBBBBBBAAAAAAAAAAAABABBAAAAAAABAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCAACACCAAAAAAAACCCCACAACCCACCCCAAAAAAAAAAAA...

result:

wrong answer Token "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...AAAAAAAAAAAAAACAAAAAAAAAAAAAAAA" doesn't correspond to pattern "[BC]*"

Subtask #8:

score: 0
Wrong Answer

Test #8:

score: 0
Wrong Answer
time: 3ms
memory: 4700kb

input:

11

output:

ABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

result:

wrong answer Token "ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB...ACAACACAAAACCACCCCCAACAACACCACA" doesn't correspond to pattern "[BC]*"

Subtask #9:

score: 0
Wrong Answer

Test #9:

score: 0
Wrong Answer
time: 20ms
memory: 6628kb

input:

12

output:

BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBABAABABBAAAAAAAABBBBABAABBBABBBBAAAAAAAAAAAA...

result:

wrong answer Token "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" doesn't correspond to pattern "[BC]*"

Subtask #10:

score: 0
Wrong Answer

Test #10:

score: 0
Wrong Answer
time: 65ms
memory: 8276kb

input:

13

output:

ABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

result:

wrong answer Token "ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB...AAACCACAAAACCACCCCCAACAACACCACA" doesn't correspond to pattern "[BC]*"

Subtask #11:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 248ms
memory: 18624kb

input:

14

output:

BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

result:

wrong answer Token "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" doesn't correspond to pattern "[BC]*"

Subtask #12:

score: 0
Wrong Answer

Test #12:

score: 0
Wrong Answer
time: 978ms
memory: 26352kb

input:

15

output:

ABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

result:

wrong answer Token "ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB...AAACCACAAAACCACCCCCAACAACACCACA" doesn't correspond to pattern "[BC]*"

Subtask #13:

score: 0
Time Limit Exceeded

Test #13:

score: 0
Time Limit Exceeded

input:

16

output:


result:


Subtask #14:

score: 0
Time Limit Exceeded

Test #14:

score: 0
Time Limit Exceeded

input:

17

output:


result:


Subtask #15:

score: 0
Time Limit Exceeded

Test #15:

score: 0
Time Limit Exceeded

input:

18

output:


result: