QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#150651 | #4327. Šeširi | penguinman | 0 | 1185ms | 35656kb | C++17 | 2.1kb | 2023-08-25 23:02:35 | 2023-08-25 23:02:37 |
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]] = 'C';
}
else{
ans[idx[m]][bit[m]] = 'B';
}
}
};
REP(i,0,2<<N){
if(visited[i]) continue;
dfs(i);
}
rep(i,0,N) cout << ans[i] << ln;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3544kb
input:
4
output:
CBCBBBCB BCBBCCBB CBCCBBCC BCBBCCCC
result:
wrong answer your plan fails on CCBB
Subtask #2:
score: 0
Wrong Answer
Test #2:
score: 0
Wrong Answer
time: 1ms
memory: 3412kb
input:
5
output:
CBCBBBCBCBCCBBCB CCBCCCBCBCBBCCBB BBCCBBCBCBCCBBCC CCBBCBCCBCBBCCBC BBCCBCCBCCCCCBCC
result:
wrong answer your plan fails on CCCCB
Subtask #3:
score: 0
Wrong Answer
Test #3:
score: 0
Wrong Answer
time: 1ms
memory: 3572kb
input:
6
output:
CBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCB BCBBCCBCBCBBCCBBCCBBCCBCBCBBCCBB CBCCBBCBCBCCBBCBBBCCBBCBCBCCBBCB BCBBCCCCBBBBBCBCCCBBCCCCBBBBBCBC CBCBBBBBCCBCCBCCBBCBBBBBCCBCCBCC BCBCCCCCBBCCBBBBCCCCCCCBCCCCCCCC
result:
wrong answer your plan fails on CCBBBB
Subtask #4:
score: 0
Wrong Answer
Test #4:
score: 0
Wrong Answer
time: 1ms
memory: 3608kb
input:
7
output:
CBCBBBCBCBCCBBCBBBCBBBCBCBCCCBCBCBCCBBCCCBCBBCBCBBCBBBCBCBCCBBCB CCBCCCBCBCBBCCBBCCBCCCBCBCBBBCBCBCBBCCBBBCBCCBCBCCBBCCBCBCBBCCBB BBCCBBCBCBCCBBCCBBCBBBCBCBCCCBCBCBCCBBCBCBCCBCBCBBCCCBCBBBCCBBCB CCBBCBCCBCBBCCBCCCBCCBCCBBCBBCBCBCBBCCBCBCBBCBCBCCBBBCCCCBBBBCBC BBCCBCCBCCCCCBCCBBCBBBBBCBBCCBCBCBCCBCCB...
result:
wrong answer your plan fails on CCCCBBB
Subtask #5:
score: 0
Wrong Answer
Test #5:
score: 0
Wrong Answer
time: 1ms
memory: 3740kb
input:
8
output:
CBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCBCBCCBBCBCBCCCBCCBBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCBBBCBBCBBCBCCBBCBCBCCBBCBCBCCCBCCBBCBBBCBCBCCBBCB BCBBCCBCBCBBCCBBCCBCCCBCBCBBCCBCBCBBCCBCBCBBBCBBCCBBCCBCBCBBCCBBCCBBCCBCBCBBCCBBCCBCCBCCBCBBCCBCBCBBCCBCBCBBBCBBCCBBCCBCBCBBCCBB CBCCBBCBCBCCBBCBBBCBBBCBCBCCBBCBCBCCBBCBCB...
result:
wrong answer your plan fails on CCBBBBBB
Subtask #6:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 2ms
memory: 3848kb
input:
9
output:
CBCBBBCBCBCCBBCBBBCBBBCBCBCCCBCBCBCCBBCCCBCBBCBCBBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCBBBCBBCBBCBCCBBCBCBCCCBCBBBCCCBCCCBCCBBCBCBCCCBCBCBCCBBCCCBCBCCBCBBCCBBCBCBCCBBCCCBCBBCBBCBCCCBCBBBCBCBCCBBCBBBCCBBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCBCBCCBBCBCBCCCBCCBBCBBBCBCBCCBBCB CCBCCCBCBCBBCCBBCCBCCCBCBCBBBCBCBCBBCCBBBCB...
result:
wrong answer your plan fails on CCCCBBBBB
Subtask #7:
score: 0
Wrong Answer
Test #7:
score: 0
Wrong Answer
time: 1ms
memory: 4360kb
input:
10
output:
CBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCBCBCCBBCBCBCCCBCCBBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCBBBCBBCBBCBCCBBCBCBCCBBCBCBCCCBCCBBCBBBCBCBCCBBCBCBCCBBCBCBCCCBCCBBCBBBCBCBCCBBCBCBCCBBCBCBCCCBCCCBCCBBCBCBCCCBCCBBCBBBCBCBCCBBCBBBCBBCBBCBCCBBCBCBCCBBCBCBCCCBCCBBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCBCBCCBBCBCBCC...
result:
wrong answer your plan fails on CCBBBBBBBB
Subtask #8:
score: 0
Wrong Answer
Test #8:
score: 0
Wrong Answer
time: 8ms
memory: 4872kb
input:
11
output:
CBCBBBCBCBCCBBCBBBCBBBCBCBCCCBCBCBCCBBCCCBCBBCBCBBCBBBCBCBCCBBCBBBCBBBCBCBCCCBCBBBCBBCBBCBCCBBCBCBCCCBCBBBCCCBCCCBCCBBCBCBCCCBCBCBCCBBCCCBCBBCBCBBCCBBCBCBCCBBCCCBCBBCBBCBCCCBCBBBCBCBCCBBCBBBCCBBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCBCBCCBBCBCBCCCBCCBBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCBBBCBBCBBCBCCBBCBCBCCBBCBCBCC...
result:
wrong answer your plan fails on CCCCBBBBBBB
Subtask #9:
score: 0
Wrong Answer
Test #9:
score: 0
Wrong Answer
time: 17ms
memory: 7460kb
input:
12
output:
CBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCBCBCCBBCBCBCCCBCCBBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCBBBCBBCBBCBCCBBCBCBCCBBCBCBCCCBCCBBCBBBCBCBCCBBCBCBCCBBCBCBCCCBCCBBCBBBCBCBCCBBCBCBCCBBCBCBCCCBCCCBCCBBCBCBCCCBCCBBCBBBCBCBCCBBCBBBCBBCBBCBCCBBCBCBCCBBCBCBCCCBCCBBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCBCBCCBBCBCBCC...
result:
wrong answer your plan fails on CCBBBBBBBBBB
Subtask #10:
score: 0
Wrong Answer
Test #10:
score: 0
Wrong Answer
time: 82ms
memory: 10516kb
input:
13
output:
CBCBBBCBCBCCBBCBBBCBBBCBCBCCCBCBCBCCBBCCCBCBBCBCBBCBBBCBCBCCBBCBBBCBBBCBCBCCCBCBBBCBBCBBCBCCBBCBCBCCCBCBBBCCCBCCCBCCBBCBCBCCBBCBCBCCBBCCCBCBBCBCBBCCBBCBCBCCBBCCCBCBBCBBCBCCCBCBBBCBCCBCBBCBCBCCBBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCBCBCCBBCBCBCCCBCCBBCBBBCBCBCCBBCBBBCBBBCBCBCCCBCBBBCBBCBBCBCCBBCBCBCCCBCBBBCC...
result:
wrong answer your plan fails on CCCCBBBBBBBBB
Subtask #11:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 312ms
memory: 22784kb
input:
14
output:
CBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCBCBCCBBCBCBCCCBCCBBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCBBBCBBCBBCBCCBBCBCBCCBBCBCBCCCBCCBBCBBBCBCBCCBBCBCBCCBBCBCBCCCBCCBBCBBBCBCBCCBBCBCBCCBBCBCBCCCBCCCBCCBBCBCBCCCBCCBBCBBBCBCBCCBBCBBBCBBCBBCBCCBBCBCBCCBBCBCBCCCBCCBBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCBCBCCBBCBCBCC...
result:
wrong answer your plan fails on CCBBBBBBBBBBBB
Subtask #12:
score: 0
Wrong Answer
Test #12:
score: 0
Wrong Answer
time: 1185ms
memory: 35656kb
input:
15
output:
CBCBBBCBCBCCBBCBBBCBBBCBCBCCCBCBCBCCBBCCCBCBBCBCBBCBBBCBCBCCBBCBBBCBBBCBCBCCCBCBBBCBBCBBCBCCBBCBCBCCCBCBBBCCCBCCCBCCBBCBCBCCBBCBCBCCBBCCCBCBBCBCBBCCBBCBCBCCBBCCCBCBBCBBCBCCCBCBBBCBCCBCBBCBCBCCBBCBBBCBCBCCBBCBBBCBBBCBCBCCBBCBCBCCBBCBCBCCCBCCBBCBBBCBCBCCBBCBBBCBBBCBCBCCCBCBBBCBBCBBCBCCBBCBCBCCCBCBBBCC...
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