QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#526014#4327. ŠeširiNianFeng100 ✓426ms287008kbC++141.6kb2024-08-21 09:39:192024-08-21 09:39:19

Judging History

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

  • [2024-08-21 09:39:19]
  • 评测
  • 测评结果:100
  • 用时:426ms
  • 内存:287008kb
  • [2024-08-21 09:39:19]
  • 提交

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: 6ms
memory: 34472kb

input:

4

output:

CCBBCCCC
BBCCBBCC
CCBBCCBB
BBCBBBCB

result:

ok good plan!

Subtask #2:

score: 7
Accepted

Test #2:

score: 7
Accepted
time: 6ms
memory: 36592kb

input:

5

output:

BBCBBBBBCCBCCBCC
CCBBCCCCBBBBBCBC
BBCCBBCBCBCCBBCB
CCBBCCBCBCBBCCBB
BBCBBBCBCBCCBBCB

result:

ok good plan!

Subtask #3:

score: 7
Accepted

Test #3:

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

input:

6

output:

CCBCCCCCBBCCBBBBCCCCCCCBCCCCCCCC
BBCBBBBBCCBCCBCCBBCBBBBBCCBCCBCC
CCBBCCCCBBBBBCBCCCBBCCCCBBBBBCBC
BBCCBBCBCBCCBBCBBBCCBBCBCBCCBBCB
CCBBCCBCBCBBCCBBCCBBCCBCBCBBCCBB
BBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCB

result:

ok good plan!

Subtask #4:

score: 7
Accepted

Test #4:

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

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: 38748kb

input:

8

output:

CCBCCCCCBCCCCBBCCCCCCCCCCCCCCCCCBBCBBBBBCCBBCCCCBBBBBBBCBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCBCCBCCBCCCCCCCCCCCCCCCBCCCCCCCCCCCCCCCC
BBCBBBBBCBBCBBCBBBBBBBBBBBBBBBBBCCBCCCCCBCCCCBBCCBCCBCCBCCCCCBCCBBCBBBBBCBBCBBCBBBBBBBBBBBBBBBBBCCBCCCCCBCCCCBBCCBCCBCCBCCCCCBCC
CCBCCCCCBBCBBCBBCCCCCCCBCCCCCCCCBBBBBBBBBB...

result:

ok good plan!

Subtask #6:

score: 7
Accepted

Test #6:

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

input:

9

output:

BBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBCBBCBCCBBBBBCBBCBBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBCBBCBCCBBBBBCBBBCCBCCCCCBBBCCBBCCCCCCCCCCCCCCCCCBCCBCBBCCCBCCBCCBBBBBBBCBCCBBBBCCCBCBCCCCCCBCCBCCCCCCCCCCBBCCCCBBCCBCBBCCCCCBCCCCCBCCCCBBCCCCBCC
CCBCCCCCBCCBCCBCCCCCCCCCCBBCCCCCBBCBBBBBCCC...

result:

ok good plan!

Subtask #7:

score: 7
Accepted

Test #7:

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

input:

10

output:

CCBCCCCCBCCCCBBCCCCCCCCCCCCCCCCCBCCBCBBCCCBCCCCCCBBCBCCCBCCBCBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBBCBBBBBCBBBBCCBBBBBBBBBBBBBBBBBCCBCCCCCBBCCBBBBCCCCCCCBCCCCCCCCBBBBBBBBBBBBBBBBBBBBBBBBBCBBCBBCBBBBBBBBBBBBBBBCBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok good plan!

Subtask #8:

score: 7
Accepted

Test #8:

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

input:

11

output:

BBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBCBBCBCCBBBBBCBBCBBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBCCBCBBCCBBCBBCBBBBBBCCBBCCBCBBBCBBCBCCBBBBBCBBCBCCBCBBCCBBCBCCBBBBBBBBBBBBBBCBBCBBCBBBBBBBBBBBCBBCBCBBBBBBCBBCBBBBBBCCBBCCBCBBBCBBCBBBBBBBBBBBCBBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBCCBCBBCCBBC...

result:

ok good plan!

Subtask #9:

score: 7
Accepted

Test #9:

score: 7
Accepted
time: 10ms
memory: 45112kb

input:

12

output:

CCBCCCCCBCCCCBBCCCCCCCCCCCCCCCCCBCCBCBBCCCBCCCCCCBBCBCCCBCCBCBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCCCBCCCCCBCCCCBBCCCCCCCCCCCCCCCCCCBBCBCCBBCCBCBBCBCCBCBBCCCBCCCCCBCCBCBBCCBBCBCCCCBBCBCCBBCCBCBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok good plan!

Subtask #10:

score: 7
Accepted

Test #10:

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

input:

13

output:

BBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBCBBCBCCBBBBBCBBCBBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBCCBCBBCCBBCBBCBBBBBBCCBBCCBCBBBCBBCBCCBBBBBCBBCBCCBCBBCCBBCBCCBBBBBBBBBBBBBBCBBCBBCBBBBBBBBBBBCBBCBCBBBBBBCBBCBBBBBBCCBBBBBBBBBCBBCBBBBBCCBCBBCBBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBCCBCBBCCBBC...

result:

ok good plan!

Subtask #11:

score: 6
Accepted

Test #11:

score: 6
Accepted
time: 11ms
memory: 56412kb

input:

14

output:

CCBCCCCCBCCCCBBCCCCCCCCCCCCCCCCCBCCBCBBCCCBCCCCCCBBCBCCCBCCBCBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCCCBCCCCCBCCCCBBCCCCCCCCCCCCCCCCCCBBCBCCBBCCBCBBCBCCBCBBCCCBCCCCCBCCBCBBCCBBCBCCCCBBCBCCBBCCBCBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok good plan!

Subtask #12:

score: 6
Accepted

Test #12:

score: 6
Accepted
time: 24ms
memory: 62260kb

input:

15

output:

BBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBCBBCBCCBBBBBCBBCBBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBCCBCBBCCBBCBBCBBBBBBCCBBCCBCBBBCBBCBCCBBBBBCBBCBCCBCBBCCBBCBCCBBBBBBBBBBBBBBCBBCBBCBBBBBBBBBBBCBBCBCBBBBBBCBBCBBBBBBCCBBCCBCBBBCBBCBBBBBBBBBBBCBBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBCCBCBBCCBBC...

result:

ok good plan!

Subtask #13:

score: 6
Accepted

Test #13:

score: 6
Accepted
time: 73ms
memory: 100032kb

input:

16

output:

CCBCCCCCBCCCCBBCCCCCCCCCCCCCCCCCBCCBCBBCCCBCCCCCCBBCBCCCBCCBCBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCCCBCCCCCBCCCCBBCCCCCCCCCCCCCCCCCCBBCBCCBBCCBCBBCBCCBCBBCCCBCCCCCBCCBCBBCCBBCBCCCCBBCBCCBBCCBCBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok good plan!

Subtask #14:

score: 6
Accepted

Test #14:

score: 6
Accepted
time: 194ms
memory: 126700kb

input:

17

output:

BBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBCBBCBCCBBBBBCBBCBBCBBBBBCBBCBBCBBBBBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBCCBCBBCCBBCBBCBBBBBBCCBBCBBCBBBCBBCBCCBBBBBCBBCBCCBCBBCCBBCBCCBBBBBBBBBBBBBBCBBCBBCBBBBBBCBBBBCBBCBCBBBBBBCBBCBBBBBBCCBBCBBCBBBCBBCBBBBBBCBBBBCBCBBBBBBCBBCBBCBBBBBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBCCBCBBCCBBC...

result:

ok good plan!

Subtask #15:

score: 6
Accepted

Test #15:

score: 6
Accepted
time: 426ms
memory: 287008kb

input:

18

output:

CCBCCCCCBCCCCBBCCCCCCCCCCCCCCCCCBCCBCBBCCCBCCCCCCBBCBCCCBCCBCBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCCCBCCCCCBCCCCBBCCCCCCCCCCCCCCCCCCBBCBCCBBCCBCBBCBCCBCBBCCCBCCCCCBCCBCBBCCBBCBCCCCBBCBCCBBCCBCBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok good plan!

Extra Test:

score: 0
Extra Test Passed