QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#526015#4327. ŠeširiNianFeng100 ✓361ms286664kbC++141.5kb2024-08-21 09:39:572024-08-21 09:39:59

Judging History

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

  • [2024-08-21 09:39:59]
  • 评测
  • 测评结果:100
  • 用时:361ms
  • 内存:286664kb
  • [2024-08-21 09:39:57]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int n;
char ans[20][1<<20];
vector<pair<int,int> >G[1<<20];
int tot,tmp;
int cur[1<<20];
int vis[1<<23];
void dfs(int x){
    for(int i=cur[x];i<G[x].size();i=cur[x]){
        cur[x]=i+1;
        int y=G[x][i].first,e=G[x][i].second;
        if(!vis[e]){
            vis[e]=1;
            if(x^1<<n+1&&y^1<<n+1){
                int p=x,q=y;
                if(p>=1<<n) p^=1<<n;
                if(q>=1<<n) q^=1<<n;
                int t=p^q;
                if(p&t) vis[e]=1;
                else vis[e]=2;
            }
            dfs(y);
        }
    }
}
int main(){
    scanf("%d",&n);
    for(int x=0;x<1<<n;x++){
        for(int i=1;i<=n;i++){
            if(x>>i-1&1){
                int y=x^1<<i-1|1<<n;
                tot++;
                G[x].push_back(make_pair(y,tot));
                G[y].push_back(make_pair(x,tot));
            }
        }
    }
    for(int i=0;i<1<<n+1;i++){
        if(G[i].size()&1){
            tot++;
            G[i].push_back(make_pair(1<<n+1,tot));
            G[1<<n+1].push_back(make_pair(i,tot));
        }
    }
    for(int i=0;i<=1<<n+1;i++){
        dfs(i);
    }
    for(int x=0;x<1<<n;x++){
        for(int i=1;i<=n;i++){
            if(x>>i-1&1){
                tmp++;
                int upp=x>>i;
                int low=x&(1<<i-1)-1;
                ans[i][upp<<i-1|low]='A'+vis[tmp];
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=0;j<1<<n-1;j++){
            putchar(ans[n-i+1][j]);
        }
        putchar('\n');
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 7
Accepted

Test #1:

score: 7
Accepted
time: 0ms
memory: 34520kb

input:

4

output:

CCBBCCCC
BBCCBBCC
CCBBCCBB
BBCBBBCB

result:

ok good plan!

Subtask #2:

score: 7
Accepted

Test #2:

score: 7
Accepted
time: 0ms
memory: 34464kb

input:

5

output:

BBCBBBBBCCBCCBCC
CCBBCCCCBBBBBCBC
BBCCBBCBCBCCBBCB
CCBBCCBCBCBBCCBB
BBCBBBCBCBCCBBCB

result:

ok good plan!

Subtask #3:

score: 7
Accepted

Test #3:

score: 7
Accepted
time: 0ms
memory: 36528kb

input:

6

output:

CCBCCCCCBBCCBBBBCCCCCCCBCCCCCCCC
BBCBBBBBCCBCCBCCBBCBBBBBCCBCCBCC
CCBBCCCCBBBBBCBCCCBBCCCCBBBBBCBC
BBCCBBCBCBCCBBCBBBCCBBCBCBCCBBCB
CCBBCCBCBCBBCCBBCCBBCCBCBCBBCCBB
BBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCB

result:

ok good plan!

Subtask #4:

score: 7
Accepted

Test #4:

score: 7
Accepted
time: 3ms
memory: 38668kb

input:

7

output:

BBCBBBBBCBBCBBCBBBBBBBBBBBBBCBBBCCBCCCCCBCCCBBBCCCBCCCCBBCCCCBCC
CCBCCCCCBBCBBCBBCCCCCCCBCCCCBCCCBBBBBBBBBBBBCBBBBBCBBBBCCCBBCCBC
BBCBBBBBCCBCCBCCBBCBBBBBCBBCCBCBCBCCBCCBCCCCBBCCBBCBCBBBBBBCBBCC
CCBBCCCCBBBBBCBCCCBCCBCCBBCBBCBCBCBBCCBCBCBBCCBBCCBBBCCCCBBBBCBB
BBCCBBCBCBCCBBCBBBCBBBCBCBCCCBCBCBCCBBCB...

result:

ok good plan!

Subtask #5:

score: 7
Accepted

Test #5:

score: 7
Accepted
time: 0ms
memory: 38672kb

input:

8

output:

CCBCCCCCBCCCCBBCCCCCCCCCCCCCCCCCBBCBBBBBCCBBCCCCBBBBBBBCBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCBCCBCCBCCCCCCCCCCCCCCCBCCCCCCCCCCCCCCCC
BBCBBBBBCBBCBBCBBBBBBBBBBBBBBBBBCCBCCCCCBCCCCBBCCBCCBCCBCCCCCBCCBBCBBBBBCBBCBBCBBBBBBBBBBBBBBBBBCCBCCCCCBCCCCBBCCBCCBCCBCCCCCBCC
CCBCCCCCBBCBBCBBCCCCCCCBCCCCCCCCBBBBBBBBBB...

result:

ok good plan!

Subtask #6:

score: 7
Accepted

Test #6:

score: 7
Accepted
time: 0ms
memory: 38676kb

input:

9

output:

BBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBCBBCBCCBBBBBCBBCBBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBCBBCBCCBBBBBCBBBCCBCCCCCBBBCCBBCCCCCCCCCCCCCCCCCBCCBCBBCCCBCCBCCBBBBBBBCBCCBBBBCCCBCBCCCCCCBCCBCCCCCCCCCCBBCCCCBBCCBCBBCCCCCBCCCCCBCCCCBBCCCCBCC
CCBCCCCCBCCBCCBCCCCCCCCCCBBCCCCCBBCBBBBBCCC...

result:

ok good plan!

Subtask #7:

score: 7
Accepted

Test #7:

score: 7
Accepted
time: 0ms
memory: 41032kb

input:

10

output:

CCBCCCCCBCCCCBBCCCCCCCCCCCCCCCCCBCCBCBBCCCBCCCCCCBBCBCCCBCCBCBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBBCBBBBBCBBBBCCBBBBBBBBBBBBBBBBBCCBCCCCCBBCCBBBBCCCCCCCBCCCCCCCCBBBBBBBBBBBBBBBBBBBBBBBBBCBBCBBCBBBBBBBBBBBBBBBCBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok good plan!

Subtask #8:

score: 7
Accepted

Test #8:

score: 7
Accepted
time: 3ms
memory: 41492kb

input:

11

output:

BBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBCBBCBCCBBBBBCBBCBBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBCCBCBBCCBBCBBCBBBBBBCCBBCCBCBBBCBBCBCCBBBBBCBBCBCCBCBBCCBBCBCCBBBBBBBBBBBBBBCBBCBBCBBBBBBBBBBBCBBCBCBBBBBBCBBCBBBBBBCCBBCCBCBBBCBBCBBBBBBBBBBBCBBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBCCBCBBCCBBC...

result:

ok good plan!

Subtask #9:

score: 7
Accepted

Test #9:

score: 7
Accepted
time: 12ms
memory: 45352kb

input:

12

output:

CCBCCCCCBCCCCBBCCCCCCCCCCCCCCCCCBCCBCBBCCCBCCCCCCBBCBCCCBCCBCBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCCCBCCCCCBCCCCBBCCCCCCCCCCCCCCCCCCBBCBCCBBCCBCBBCBCCBCBBCCCBCCCCCBCCBCBBCCBBCBCCCCBBCBCCBBCCBCBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok good plan!

Subtask #10:

score: 7
Accepted

Test #10:

score: 7
Accepted
time: 11ms
memory: 46636kb

input:

13

output:

BBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBCBBCBCCBBBBBCBBCBBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBCCBCBBCCBBCBBCBBBBBBCCBBCCBCBBBCBBCBCCBBBBBCBBCBCCBCBBCCBBCBCCBBBBBBBBBBBBBBCBBCBBCBBBBBBBBBBBCBBCBCBBBBBBCBBCBBBBBBCCBBBBBBBBBCBBCBBBBBCCBCBBCBBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBCCBCBBCCBBC...

result:

ok good plan!

Subtask #11:

score: 6
Accepted

Test #11:

score: 6
Accepted
time: 16ms
memory: 56656kb

input:

14

output:

CCBCCCCCBCCCCBBCCCCCCCCCCCCCCCCCBCCBCBBCCCBCCCCCCBBCBCCCBCCBCBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCCCBCCCCCBCCCCBBCCCCCCCCCCCCCCCCCCBBCBCCBBCCBCBBCBCCBCBBCCCBCCCCCBCCBCBBCCBBCBCCCCBBCBCCBBCCBCBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok good plan!

Subtask #12:

score: 6
Accepted

Test #12:

score: 6
Accepted
time: 26ms
memory: 62120kb

input:

15

output:

BBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBCBBCBCCBBBBBCBBCBBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBCCBCBBCCBBCBBCBBBBBBCCBBCCBCBBBCBBCBCCBBBBBCBBCBCCBCBBCCBBCBCCBBBBBBBBBBBBBBCBBCBBCBBBBBBBBBBBCBBCBCBBBBBBCBBCBBBBBBCCBBCCBCBBBCBBCBBBBBBBBBBBCBBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBCCBCBBCCBBC...

result:

ok good plan!

Subtask #13:

score: 6
Accepted

Test #13:

score: 6
Accepted
time: 56ms
memory: 99864kb

input:

16

output:

CCBCCCCCBCCCCBBCCCCCCCCCCCCCCCCCBCCBCBBCCCBCCCCCCBBCBCCCBCCBCBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCCCBCCCCCBCCCCBBCCCCCCCCCCCCCCCCCCBBCBCCBBCCBCBBCBCCBCBBCCCBCCCCCBCCBCBBCCBBCBCCCCBBCBCCBBCCBCBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok good plan!

Subtask #14:

score: 6
Accepted

Test #14:

score: 6
Accepted
time: 158ms
memory: 127060kb

input:

17

output:

BBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBCBBCBCCBBBBBCBBCBBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBCCBCBBCCBBCBBCBBBBBBCCBBCBBCBBBCBBCBCCBBBBBCBBCBCCBCBBCCBBCBCCBBBBBBBBBBBBBBCBBCBBCBBBBBBCBBBBCBBCBCBBBBBBCBBCBBBBBBCCBBCBBCBBBCBBCBBBBBBCBBBBCBCBBBBBBCBBCBBCBBBBBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBCCBCBBCCBBC...

result:

ok good plan!

Subtask #15:

score: 6
Accepted

Test #15:

score: 6
Accepted
time: 361ms
memory: 286664kb

input:

18

output:

CCBCCCCCBCCCCBBCCCCCCCCCCCCCCCCCBCCBCBBCCCBCCCCCCBBCBCCCBCCBCBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCCCBCCCCCBCCCCBBCCCCCCCCCCCCCCCCCCBBCBCCBBCCBCBBCBCCBCBBCCCBCCCCCBCCBCBBCCBBCBCCCCBBCBCCBBCCBCBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok good plan!

Extra Test:

score: 0
Extra Test Passed