QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#150656 | #4327. Šeširi | penguinman | 0 | 1179ms | 37996kb | C++17 | 2.3kb | 2023-08-25 23:23:00 | 2023-08-25 23:23:02 |
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)){
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);
assert(0 <= val && val < ((1<<(N-1))));
idx.pb(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++;
}
}
assert(edge[2<<N].size()%2 == 0);
vector<string> ans(N, string(1<<(N-1),'A'));
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){
assert(next%2 == 0);
ans[idx[m]][bit[m]] = 'B';
}
else{
assert(next%2);
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: 3748kb
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: 3596kb
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: 0ms
memory: 3776kb
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: 1ms
memory: 3640kb
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: 1ms
memory: 3724kb
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: 4144kb
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: 1ms
memory: 4636kb
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: 8ms
memory: 5144kb
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: 20ms
memory: 7948kb
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: 80ms
memory: 11180kb
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: 308ms
memory: 25156kb
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: 1179ms
memory: 37996kb
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