QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#150668 | #4327. Šeširi | penguinman | 0 | 967ms | 26420kb | C++17 | 2.1kb | 2023-08-25 23:54:21 | 2023-08-25 23:54:21 |
Judging History
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;
vector<bool> visited, used;
vector<string> ans;
ll N;
vi mem;
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(now == (2<<N) || next == (2<<N)) continue;
ll l = now/2, r = next/2;
ll idx = mem[l^r];
ll bit = (l&((1<<(idx))-1))+(l>>(idx+1)<<idx);
if(now%2){
ans[idx][bit] = 'B';
}
else{
ans[idx][bit] = 'C';
}
}
};
int main(){
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
cin >> N;
mem.resize(1<<N);
rep(i,0,N) mem[1<<i] = i;
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);
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,N){
cout << ans[i] << ln;
}
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3512kb
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: 3624kb
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: 3608kb
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: 3648kb
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: 0ms
memory: 3904kb
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: 4068kb
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: 3ms
memory: 4300kb
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: 6ms
memory: 4768kb
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: 6840kb
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: 68ms
memory: 8288kb
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: 254ms
memory: 18604kb
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: 967ms
memory: 26420kb
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