QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#150649 | #4327. Šeširi | penguinman | 0 | 1232ms | 35524kb | C++17 | 2.1kb | 2023-08-25 23:00:03 | 2023-08-25 23:00:06 |
Judging History
answer
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::string;
using ll = long long;
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()
constexpr ll inf = 1e18;
int main(){
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
ll N; cin >> N;
vii edge((2<<N)+1), weight((2<<N)+1);
vi idx, bit;
ll M = 0;
rep(i,0,1<<N){
rep(j,0,N){
if(i & (1<<j)){
edge[i*2].pb((i-(1<<j))*2+1);
weight[i*2].pb(M);
edge[(i-(1<<j))*2+1].pb(i*2);
weight[(i-(1<<j))*2+1].pb(M);
idx.pb(j);
ll val = 0;
val += (i&((1<<j)-1));
val += ((i>>(j+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++;
}
}
vector<string> ans(N, string(1<<(N-1),'B'));
vector<bool> used(M);
vector<bool> visited((2<<N)+1);
std::function<void(ll)> 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';
}
}
};
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: 3548kb
input:
4
output:
BCBCCCBC CBCCBBCC BCBBCCBB CBCCBBBB
result:
wrong answer your plan fails on CCCC
Subtask #2:
score: 0
Wrong Answer
Test #2:
score: 0
Wrong Answer
time: 1ms
memory: 3488kb
input:
5
output:
BCBCCCBCBCBBCCBC BBCBBBCBCBCCBBCC CCBBCCBCBCBBCCBB BBCCBCBBCBCCBBCB CCBBCBBCBBBBBCBB
result:
wrong answer your plan fails on CCCCC
Subtask #3:
score: 0
Wrong Answer
Test #3:
score: 0
Wrong Answer
time: 1ms
memory: 3468kb
input:
6
output:
BCBCCCBCBCBBCCBCCCBCCCBCBCBBCCBC CBCCBBCBCBCCBBCCBBCCBBCBCBCCBBCC BCBBCCBCBCBBCCBCCCBBCCBCBCBBCCBC CBCCBBBBCCCCCBCBBBCCBBBBCCCCCBCB BCBCCCCCBBCBBCBBCCBCCCCCBBCBBCBB CBCBBBBBCCBBCCCCBBBBBBBCBBBBBBBB
result:
wrong answer your plan fails on CCCCBB
Subtask #4:
score: 0
Wrong Answer
Test #4:
score: 0
Wrong Answer
time: 0ms
memory: 3496kb
input:
7
output:
BCBCCCBCBCBBCCBCCCBCCCBCBCBBBCBCBCBBCCBBBCBCCBCBCCBCCCBCBCBBCCBC BBCBBBCBCBCCBBCCBBCBBBCBCBCCCBCBCBCCBBCCCBCBBCBCBBCCBBCBCBCCBBCC CCBBCCBCBCBBCCBBCCBCCCBCBCBBBCBCBCBBCCBCBCBBCBCBCCBBBCBCCCBBCCBC BBCCBCBBCBCCBBCBBBCBBCBBCCBCCBCBCBCCBBCBCBCCBCBCBBCCCBBBBCCCCBCB CCBBCBBCBBBBBCBBCCBCCCCCBCCBBCBCBCBBCBBC...
result:
wrong answer your plan fails on CCCCBBB
Subtask #5:
score: 0
Wrong Answer
Test #5:
score: 0
Wrong Answer
time: 2ms
memory: 3740kb
input:
8
output:
BCBCCCBCBCBBCCBCCCBCCCBCBCBBCCBCBCBBCCBCBCBBBCBBCCBCCCBCBCBBCCBCCCBCCCBCBCBBCCBCCCBCCBCCBCBBCCBCBCBBCCBCBCBBBCBBCCBCCCBCBCBBCCBC CBCCBBCBCBCCBBCCBBCBBBCBCBCCBBCBCBCCBBCBCBCCCBCCBBCCBBCBCBCCBBCCBBCCBBCBCBCCBBCCBBCBBCBBCBCCBBCBCBCCBBCBCBCCCBCCBBCCBBCBCBCCBBCC BCBBCCBCBCBBCCBCCCBCCCBCBCBBCCBCBCBBCCBCBC...
result:
wrong answer your plan fails on CCCCBBBB
Subtask #6:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 2ms
memory: 3844kb
input:
9
output:
BCBCCCBCBCBBCCBCCCBCCCBCBCBBBCBCBCBBCCBBBCBCCBCBCCBCCCBCBCBBCCBCCCBCCCBCBCBBCCBCCCBCCBCCBCBBCCBCBCBBBCBCCCBBBCBBBCBBCCBCBCBBBCBCBCBBCCBBBCBCBBCBCCBBCCBCBCBBCCBBBCBCCBCCBCBBBCBCCCBCBCBBCCBCCCBBCCBCCCBCBCBBCCBCCCBCCCBCBCBBCCBCBCBBCCBCBCBBBCBBCCBCCCBCBCBBCCBC BBCBBBCBCBCCBBCCBBCBBBCBCBCCCBCBCBCCBBCCCBC...
result:
wrong answer your plan fails on CCCCBBBBB
Subtask #7:
score: 0
Wrong Answer
Test #7:
score: 0
Wrong Answer
time: 4ms
memory: 4492kb
input:
10
output:
BCBCCCBCBCBBCCBCCCBCCCBCBCBBCCBCBCBBCCBCBCBBBCBBCCBCCCBCBCBBCCBCCCBCCCBCBCBBCCBCCCBCCBCCBCBBCCBCBCBBCCBCBCBBBCBBCCBCCCBCBCBBCCBCBCBBCCBCBCBBBCBBCCBCCCBCBCBBCCBCBCBBCCBCBCBBBCBBBCBBCCBCBCBBBCBBCCBCCCBCBCBBCCBCCCBCCBCCBCBBCCBCBCBBCCBCBCBBBCBBCCBCCCBCBCBBCCBCCCBCCCBCBCBBCCBCCCBCCCBCBCBBCCBCBCBBCCBCBCBB...
result:
wrong answer your plan fails on CCCCBBBBBB
Subtask #8:
score: 0
Wrong Answer
Test #8:
score: 0
Wrong Answer
time: 10ms
memory: 4856kb
input:
11
output:
BCBCCCBCBCBBCCBCCCBCCCBCBCBBBCBCBCBBCCBBBCBCCBCBCCBCCCBCBCBBCCBCCCBCCCBCBCBBBCBCCCBCCBCCBCBBCCBCBCBBBCBCCCBBBCBBBCBBCCBCBCBBBCBCBCBBCCBBBCBCCBCBCCBBCCBCBCBBCCBBBCBCCBCCBCBBBCBCCCBCBCBBCCBCCCBBCCBCCCBCBCBBCCBCCCBCCCBCBCBBCCBCBCBBCCBCBCBBBCBBCCBCCCBCBCBBCCBCCCBCCCBCBCBBCCBCCCBCCBCCBCBBCCBCBCBBCCBCBCBB...
result:
wrong answer your plan fails on CCCCBBBBBBB
Subtask #9:
score: 0
Wrong Answer
Test #9:
score: 0
Wrong Answer
time: 25ms
memory: 7416kb
input:
12
output:
BCBCCCBCBCBBCCBCCCBCCCBCBCBBCCBCBCBBCCBCBCBBBCBBCCBCCCBCBCBBCCBCCCBCCCBCBCBBCCBCCCBCCBCCBCBBCCBCBCBBCCBCBCBBBCBBCCBCCCBCBCBBCCBCBCBBCCBCBCBBBCBBCCBCCCBCBCBBCCBCBCBBCCBCBCBBBCBBBCBBCCBCBCBBBCBBCCBCCCBCBCBBCCBCCCBCCBCCBCBBCCBCBCBBCCBCBCBBBCBBCCBCCCBCBCBBCCBCCCBCCCBCBCBBCCBCCCBCCCBCBCBBCCBCBCBBCCBCBCBB...
result:
wrong answer your plan fails on CCCCBBBBBBBB
Subtask #10:
score: 0
Wrong Answer
Test #10:
score: 0
Wrong Answer
time: 81ms
memory: 10436kb
input:
13
output:
BCBCCCBCBCBBCCBCCCBCCCBCBCBBBCBCBCBBCCBBBCBCCBCBCCBCCCBCBCBBCCBCCCBCCCBCBCBBBCBCCCBCCBCCBCBBCCBCBCBBBCBCCCBBBCBBBCBBCCBCBCBBCCBCBCBBCCBBBCBCCBCBCCBBCCBCBCBBCCBBBCBCCBCCBCBBBCBCCCBCBBCBCCBCBCBBCCBCCCBCBCBBCCBCCCBCCCBCBCBBCCBCBCBBCCBCBCBBBCBBCCBCCCBCBCBBCCBCCCBCCCBCBCBBBCBCCCBCCBCCBCBBCCBCBCBBBCBCCCBB...
result:
wrong answer your plan fails on CCCCBBBBBBBBB
Subtask #11:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 316ms
memory: 22956kb
input:
14
output:
BCBCCCBCBCBBCCBCCCBCCCBCBCBBCCBCBCBBCCBCBCBBBCBBCCBCCCBCBCBBCCBCCCBCCCBCBCBBCCBCCCBCCBCCBCBBCCBCBCBBCCBCBCBBBCBBCCBCCCBCBCBBCCBCBCBBCCBCBCBBBCBBCCBCCCBCBCBBCCBCBCBBCCBCBCBBBCBBBCBBCCBCBCBBBCBBCCBCCCBCBCBBCCBCCCBCCBCCBCBBCCBCBCBBCCBCBCBBBCBBCCBCCCBCBCBBCCBCCCBCCCBCBCBBCCBCCCBCCCBCBCBBCCBCBCBBCCBCBCBB...
result:
wrong answer your plan fails on CCCCBBBBBBBBBB
Subtask #12:
score: 0
Wrong Answer
Test #12:
score: 0
Wrong Answer
time: 1232ms
memory: 35524kb
input:
15
output:
BCBCCCBCBCBBCCBCCCBCCCBCBCBBBCBCBCBBCCBBBCBCCBCBCCBCCCBCBCBBCCBCCCBCCCBCBCBBBCBCCCBCCBCCBCBBCCBCBCBBBCBCCCBBBCBBBCBBCCBCBCBBCCBCBCBBCCBBBCBCCBCBCCBBCCBCBCBBCCBBBCBCCBCCBCBBBCBCCCBCBBCBCCBCBCBBCCBCCCBCBCBBCCBCCCBCCCBCBCBBCCBCBCBBCCBCBCBBBCBBCCBCCCBCBCBBCCBCCCBCCCBCBCBBBCBCCCBCCBCCBCBBCCBCBCBBBCBCCCBB...
result:
wrong answer your plan fails on CCCCBBBBBBBBBBB
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