QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#150664#4327. Šeširipenguinman82 1060ms25740kbC++172.5kb2023-08-25 23:44:292023-08-25 23:44:30

Judging History

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

  • [2023-08-25 23:44:30]
  • 评测
  • 测评结果:82
  • 用时:1060ms
  • 内存:25740kb
  • [2023-08-25 23:44:29]
  • 提交

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;
vi idx, bit;
vector<bool> visited, used;
vector<string> ans;


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(m >= idx.size()) continue;
        if(now%2){
            ans[idx[m]][bit[m]] = 'B';
        }
        else{
            ans[idx[m]][bit[m]] = 'C';
        }
    }
};

int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll N; cin >> N;
    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);
                ll val = 0;
                val += (i&((1<<j)-1));
                val += ((i>>(j+1))<<j);
                idx.pb(N-1-j);
                bit.pb(val);
                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,1<<N){
        vi sum(2), ok(2);
        rep(j,0,N){
            ll val = 0;
            val += (i&((1<<j)-1));
            val += ((i>>(j+1))<<j);
            if(i&(1<<j)){
                sum[1]++;
                if(ans[j][val] == 'C') ok[1]++;
            }
            else{
                sum[0]++;
                if(ans[j][val] == 'B') ok[0]++;
            }
        }
    }*/
    rep(i,0,N){
        cout << ans[i] << ln;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 7
Accepted

Test #1:

score: 7
Accepted
time: 1ms
memory: 3596kb

input:

4

output:

CBCCBBBB
BCBBCCBB
CBCCBBCC
BCBCCCBC

result:

ok good plan!

Subtask #2:

score: 7
Accepted

Test #2:

score: 7
Accepted
time: 1ms
memory: 3480kb

input:

5

output:

CCBBCBBCBBBBBCBB
BBCCBCBBCBCCBBCB
CCBBCCBCBCBBCCBB
BBCBBBCBCBCCBBCC
BCBCCCBCBCBBCCBC

result:

ok good plan!

Subtask #3:

score: 7
Accepted

Test #3:

score: 7
Accepted
time: 1ms
memory: 3572kb

input:

6

output:

CBCBBBBBCCBBCCCCBBBBBBBCBBBBBBBB
BCBCCCCCBBCBBCBBCCBCCCCCBBCBBCBB
CBCCBBBBCCCCCBCBBBCCBBBBCCCCCBCB
BCBBCCBCBCBBCCBCCCBBCCBCBCBBCCBC
CBCCBBCBCBCCBBCCBBCCBBCBCBCCBBCC
BCBCCCBCBCBBCCBCCCBCCCBCBCBBCCBC

result:

ok good plan!

Subtask #4:

score: 7
Accepted

Test #4:

score: 7
Accepted
time: 1ms
memory: 3644kb

input:

7

output:

CCBBCBBCBBBBBCBBCBBCBCCBBCCBBBBCBBBBBBBBBBBBCBBBBBCBBBBCCBBBBCBB
BBCCBCCBCCCCCBCCBCBBCBBCBBBCCBBBCBCCBCCBCCCBBCCCBCBBCBBBBBBCBBCB
CCBBCBBCBBBBBCBBCCBCCCCCBCCBBCBCBCBBCBBCBBBBCBCBCCBCBCCCCBCBBCBB
BBCCBCBBCBCCBBCBBBCBBCBBCCBCCBCBCBCCBBCBCBCCBCBCBBCCCBBBBCCCCBCB
CCBBCCBCBCBBCCBBCCBCCCBCBCBBBCBCBCBBCCBC...

result:

ok good plan!

Subtask #5:

score: 7
Accepted

Test #5:

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

input:

8

output:

CBCBBBBBCBBBBCCBBBBBBBBBBBBBBBBBCCBCCCCCBBCCBBBBCCCCCCCBCCCCCCCCBBBBBBBBBBBBBBBBBBBBBBBBBCBBCBBCBBBBBBBBBBBBBBBCBBBBBBBBBBBBBBBB
BCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCBBCBBBBBCBBBBCCBBCBBCBBCBBBBBCBBCCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCBBCBBBBBCBBBBCCBBCBBCBBCBBBBBCBB
CBCBBBBBCCBCCBCCBBBBBBBCBBBBBBBBCCCCCCCCCC...

result:

ok good plan!

Subtask #6:

score: 7
Accepted

Test #6:

score: 7
Accepted
time: 2ms
memory: 3844kb

input:

9

output:

CCBBCBBCBBBBBCBBCBBCBCCBBBBBCBBCBBBBBBBBBCCBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBBBBCBBCBCCBCBBCCBBCBCCBBCCBCBBCCBBCBBCBBBBBBBBBBCCBBBBCBBBBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBCBBCBCCBBBBBCBBBBBCBCBBBBBBCBBCBBBBBBBBBBCCBBBBCCBBCBCCBBBBBCBBBBBCBBBBCCBBBBCBB
BBCCBCCBCCCCCBCCBCCBCBBCCCCCBCCBCCCCCCCCCBB...

result:

ok good plan!

Subtask #7:

score: 7
Accepted

Test #7:

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

input:

10

output:

CBCBBBBBCBBBBCCBBBBBBBBBBBBBBBBBCBBCBCCBBBCBBBBBBCCBCBBBCBBCBCCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCBCCCCCBCCCCBBCCCCCCCCCCCCCCCCCBBCBBBBBCCBBCCCCBBBBBBBCBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCBCCBCCBCCCCCCCCCCCCCCCBCCCCCCCCCCCCCCCCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

result:

ok good plan!

Subtask #8:

score: 7
Accepted

Test #8:

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

input:

11

output:

CCBBCBBCBBBBBCBBCBBCBCCBBBBBCBBCBBBBBBBBBCCBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBBBBCBBCBCCBCBBCCBBCBCCBBBBBBBBBBBBBBCBBCBBCBBBBBBBBBBBCBBBBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBCCBCBBCCBBCBBCBBBBBBCCBBCCBCBBBBCBBBBBCCBBBBCBBCBBCBBBBBBBBBBBCBBBBBCCBBCCBCBBBBCBBCBBCBBBBBCBBCBBCBCCBBBBBCBBCBCCBCBBCCBBCBCCBBBBBBBBBBBBB...

result:

ok good plan!

Subtask #9:

score: 7
Accepted

Test #9:

score: 7
Accepted
time: 18ms
memory: 6376kb

input:

12

output:

CBCBBBBBCBBBBCCBBBBBBBBBBBBBBBBBCBBCBCCBBBCBBBBBBCCBCBBBCBBCBCCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBBBCBBBBBCBBBBCCBBBBBBBBBBBBBBBBBBCCBCBBCCBBCBCCBCBBCBCCBBBCBBBBBCBBCBCCBBCCBCBBBBCCBCBBCCBBCBCCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

result:

ok good plan!

Subtask #10:

score: 7
Accepted

Test #10:

score: 7
Accepted
time: 67ms
memory: 8276kb

input:

13

output:

CCBBCBBCBBBBBCBBCBBCBCCBBBBBCBBCBBBBBBBBBCCBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBBBBCBBCBCCBCBBCCBBCBCCBBBBBBBBBBBBBBCBBCBBCBBBBBBBBBBBCBBBBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBCCBCBBCCBBCBBCBBBBBBCCBBCCBCBBBBCBBBBBCCBBBBCBBCBBCBBBBBCCBCBBCBBBBBCCBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBBBBCBBCBCCBCBBCCBBCBCCBBBBBBBBBBBBB...

result:

ok good plan!

Subtask #11:

score: 6
Accepted

Test #11:

score: 6
Accepted
time: 273ms
memory: 17588kb

input:

14

output:

CBCBBBBBCBBBBCCBBBBBBBBBBBBBBBBBCBBCBCCBBBCBBBBBBCCBCBBBCBBCBCCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBBBCBBBBBCBBBBCCBBBBBBBBBBBBBBBBBBCCBCBBCCBBCBCCBCBBCBCCBBBCBBBBBCBBCBCCBBCCBCBBBBCCBCBBCCBBCBCCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

result:

ok good plan!

Subtask #12:

score: 6
Accepted

Test #12:

score: 6
Accepted
time: 1060ms
memory: 25740kb

input:

15

output:

CCBBCBBCBBBBBCBBCBBCBCCBBBBBCBBCBBBBBBBBBCCBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBBBBCBBCBCCBCBBCCBBCBCCBBBBBBBBBBBBBBCBBCBBCBBBBBBBBBBBCBBBBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBCCBCBBCCBBCBBCBBBBBBCCBBCCBCBBBBCBBBBBCCBBBBCBBCBBCBBBBBBBBBBBCBBBBBCCBBCCBCBBBBCBBCBBCBBBBBCBBCBBCBCCBBBBBCBBCBCCBCBBCCBBCBCCBBBBBBBBBBBBB...

result:

ok good plan!

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: