QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#601992 | #4327. Šeširi | zhenjianuo2025 | 100 ✓ | 381ms | 97704kb | C++14 | 2.3kb | 2024-09-30 17:23:29 | 2024-09-30 17:23:30 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define piii tuple<int,int,int>
#define mp make_pair
#define mt make_tuple
#define x first
#define y second
#define fi first
#define se second
#define era erase
#define ins insert
#define it iterator2
#define lb lower_bound
#define ub upper_bound
#define exc(exp) if(exp)continue;
#define ret(exp) if(exp)return;
#define stop(exp) if(exp)break;
#define quit(sth) {sth;return;}
#define let(var...) int var;tie(var)
#define siz(vec) ((int)((vec).size()))
#define all(vec) (vec).begin(),(vec).end()
#define unq(vec) sort(all(vec)),(vec).erase(unique(all(vec)),(vec).end())
#define deb(var) cerr<<#var<<'='<<(var)<<"; "
#define debl(var) cerr<<#var<<'='<<(var)<<";\n"
#define inf (long long)(1e18)
void chkmax(int &x,int y){if(x<y)x=y;}
void chkmin(int &x,int y){if(x>y)x=y;}
const int mod=998244353;
void Add(int &x,int y){x=x+y<mod?x+y:x+y-mod;}
int qpow(int x,int y){
int ans=1;for(;y;y>>=1,(x*=x)%=mod)if(y&1)(ans*=x)%=mod;return ans;
}
int n,U,rev[1<<18];
struct edges{
int v,nxt;bool col;
}e[5400010];
int head[600010],cur[600010],deg[600010],tot=1;
void add(int u,int v){
deg[u]++,deg[v]++;
e[++tot]={v,head[u]},head[u]=tot;
e[++tot]={u,head[v]},head[v]=tot;
}
void dfs(int u){
while(cur[u]){
if(e[cur[u]^1].col){
cur[u]=e[cur[u]].nxt;exc(1);
}
int v=e[cur[u]].v;
e[cur[u]].col=1;
cur[u]=e[cur[u]].nxt;dfs(v);
}
}
void work(){
cin>>n,U=1<<n;
for(int i=0;i<U;i++){
rev[i]=(rev[i>>1]>>1)|((i&1)<<(n-1));
}
for(int i=0;i<n;i++){
for(int S=0;S<U;S++){
exc(rev[S]>>i&1);
add(rev[S],U+(rev[S]^(1<<i)));
}
}
for(int S=0;S<U+U;S++)
if(deg[S]&1)add(U+U,S);
memcpy(cur,head,sizeof cur);
for(int S=0;S<=U+U;S++)dfs(S);
tot=2;
for(int i=0;i<n;i++){
for(int S=0;S<U;S++){
exc(rev[S]>>i&1);
cout<<(e[tot].col?"C":"B"),tot+=2;
} cout<<'\n';
}
}
signed main(){
ios::sync_with_stdio(0),
cin.tie(0),cout.tie(0);
int T=1;while(T--)work();
}
/*
* CONTINUE, NON-STOPPING, FOR THE FAITH
* START TYPING IF YOU DON'T KNOW WHAT TO DO
* STOP TYPING IF YOU DON'T KNOW WHAT YOU'RE DOING
*/
详细
Subtask #1:
score: 7
Accepted
Test #1:
score: 7
Accepted
time: 0ms
memory: 9744kb
input:
4
output:
BCBBCCCC CBCCBBCC BCBBCCBB CBCBBBCB
result:
ok good plan!
Subtask #2:
score: 7
Accepted
Test #2:
score: 7
Accepted
time: 2ms
memory: 9176kb
input:
5
output:
BBCCBBBBCCCCCBCC CCBBCCCCBBBBCCBC BBCCBBBBCCCCBBCB CCBBCCBCBBBBCCBB BBCBBBBBCBBCBBCB
result:
ok good plan!
Subtask #3:
score: 7
Accepted
Test #3:
score: 7
Accepted
time: 0ms
memory: 9520kb
input:
6
output:
BCBBCCCCBBBBBBBBCCCCCCCCCCBCCBCC CBCCBBBBCCCCCCCCBBBBBBBBCCCBBCCC BCBBCCCCBBBBBBBBCCCCCCCCBBCCBBCC CBCCBBCCCCCCBBCBBBCCBBBCCCBBCCBB BCBBCCBBBBCCCCBCCCBBCCCBCCCCBBBB CBCBBBCBCBBBBBCBBBCBBBCBBBBBBCCB
result:
ok good plan!
Subtask #4:
score: 7
Accepted
Test #4:
score: 7
Accepted
time: 0ms
memory: 8160kb
input:
7
output:
BBCCBBBCCCCBCCBCBBBCBBBBBBBBBBBBCCCBCCCCCCCCCCCCCBCCBBCBCCBCCBCC CCBBCCCBBBBCBBCBCCCBCCCCCCCCCCCCBBBCBBBBBBBBBBBBCCBCCCBCBBCBCCBC BBCCBBBCCCCBCBCCBBBCBBBBBBBBBBBBCCCBCCCCCCCCCCCCBBCBBCCBCBBCCBCC CCBBCCCBBBBCCCBCCCCBCCBCBCBBCCBCBBBCCBCCBBCBBBCBCCBCCBBCBCCBBCBB BBCCBBBCCCCBBBCBBBBCCBCCCBCCBBCBCCCBBBCB...
result:
ok good plan!
Subtask #5:
score: 7
Accepted
Test #5:
score: 7
Accepted
time: 2ms
memory: 8528kb
input:
8
output:
BCBBCCCCBBBBBBCCCCCCCCBBCCCCBBCCBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCBBCCCCCCCCCCCCCCCCCCCCCCCCCCBBCCCCBBBBCCBBCCCCBBCCCCBCCBCC CBCCBBBBCCCCCCBBBBBBBBCCBBBBCCBBCCCCCCBBCCCCCCCCCCCCCCCCCCCCCCCCBBBBBBCCBBBBBBBBBBBBBBBBBBBBBBBBCCCCBBCCCCCCBBCCBBBBCCBBCCCBBCCC BCBBCCCCBBBBBBCCCCCCCCBBCCBBCCCCBBBBBBCCBB...
result:
ok good plan!
Subtask #6:
score: 7
Accepted
Test #6:
score: 7
Accepted
time: 0ms
memory: 10108kb
input:
9
output:
BBCCBBBCCCCBCCBCBBBCBBBBBCCBCCCCCCCBCCCCCBBCBBBBCCBCCCCBBBBCCCBCBBBCBBBBBCCBCCCCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCBBBBBBBBBCCCBCCCCCBBCBBBBCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBBCCCCCCCCCCBCCBBBBCCCCCBCCBBBBBCCBCBBCBBBBCCCCCBBCBCCBCCCCCBCCBBCBCCBCCBCC CCBBCCCBBBBCBBCBCCCBCCCCCBBCBBBBBBBCBBBBBCC...
result:
ok good plan!
Subtask #7:
score: 7
Accepted
Test #7:
score: 7
Accepted
time: 2ms
memory: 9120kb
input:
10
output:
BCBBCCCCBBBBBBCCCCCCCCBBCCCCBBCCBBBBBBCCBBBBBBBBBBCCCCBBCCCCCCCCCCCCCCBBCCCCCCCCCCBBBBCCBBBBBBBBCCCCBBCCCCCCCCBBBBBBBBCCCCCCBBCCBBBBBBCCBBBBBBBBBBCCCCBBCCCCCCCCBBBBCCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCBBBBBBBBBBBBBBBBBBCCCCCCBBCCCCCCCCCCBBBBCCBBBBBBBBCCCCBBCCCCCC...
result:
ok good plan!
Subtask #8:
score: 7
Accepted
Test #8:
score: 7
Accepted
time: 2ms
memory: 8492kb
input:
11
output:
BBCCBBBCCCCBCCBCBBBCBBBBBCCBCCCCCCCBCCCCCBBCBBBBCCBCCCCBBBBCCBCCBBBCBBBBBCCBCCCCBBCBBBBBBBBBBBCBBCCBCCCCCCCCBBBBCCCCCCCCCCCCCCCCCCCBCCCCCBBCBBBBCCBCCCCCCCCCCCBCCBBCBBBBBBBBCCCCBBBBBBBBBBBBBBBBCCBCCCCBBBBCCCBCCCCBCCCCCBBCBBBBBBBCBBBBBCCBCCCCCCBCCCCBBBBCCCBCBBBCBBBBBCCBCCCCBBCBBBBBBBBBBBBBBCCBCCCCCCCC...
result:
ok good plan!
Subtask #9:
score: 7
Accepted
Test #9:
score: 7
Accepted
time: 0ms
memory: 10108kb
input:
12
output:
BCBBCCCCBBBBBBCCCCCCCCBBCCCCBBCCBBBBBBCCBBBBBBBBBBCCCCBBCCCCCCCCCCCCCCBBCCCCCCCCCCBBBBCCBBBBBBBBCCCCBBCCCCCCCCBBBBBBBBCCCCBBCCCCBBBBBBCCBBBBBBBBBBCCCCBBCCCCCCCCBBBBCCBBBBBBBBBBBBBBBBBBBBBBCCBBBBCCCCBBCCCCCCCCCCCCCCCCBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBBCCCCCCCCCCBBBBCCBBBBBBBBCCCCBBCCCCCC...
result:
ok good plan!
Subtask #10:
score: 7
Accepted
Test #10:
score: 7
Accepted
time: 6ms
memory: 11852kb
input:
13
output:
BBCCBBBCCCCBCCBCBBBCBBBBBCCBCCCCCCCBCCCCCBBCBBBBCCBCCCCCBBBBCBCCBBBCBBBBBCCBCCCCBBCBBBBBBBBBBBCBBCCBCCCCCCCCBBBBCCCCCCCCCCCCCCCCCCCBCCCCCBBCBBBBCCBCCCCCCCCCCCBCCBBCBBBBBBBBCCCCBBBBBBBBBBBBBBBBCCBCCCCCBBBBCCBCCCCCCCCCCBBCBBBCBBBBBBBBBCCBCCCBCBCCBBBCCCCBCCBCBBBCBBBBBCCBCCCCBBCBBBBBBBBBBBBBBCCBCCCCCCCC...
result:
ok good plan!
Subtask #11:
score: 6
Accepted
Test #11:
score: 6
Accepted
time: 6ms
memory: 15220kb
input:
14
output:
BCBBCCCCBBBBBBCCCCCCCCBBCCCCBBCCBBBBBBCCBBBBBBBBBBCCCCBBCCCCCCCCCCCCCCBBCCCCCCCCCCBBBBCCBBBBBBBBCCCCBBCCCCCCCCCCBBBBBBBBCCBBCCCCBBBBBBCCBBBBBBBBBBCCCCBBCCCCCCCCBBBBCCBBBBBBBBBBBBBBBBBBBBBBCCBBBBCCCCBBCCCCCCCCCCCCCCCCBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBBCCCCCCCCCCBBBBCCBBBBBBBBCCCCBBCCCCCC...
result:
ok good plan!
Subtask #12:
score: 6
Accepted
Test #12:
score: 6
Accepted
time: 22ms
memory: 18940kb
input:
15
output:
BBCCBBBCCCCBCCBCBBBCBBBBBCCBCCCCCCCBCCCCCBBCBBBBCCBCCCCCBBBBCBCCBBBCBBBBBCCBCCCCBBCBBBBBBBBBBCBBBCCBCCCCCCCCBBCBCCCCCCCCCCCCCCCCCCCBCCCCCBBCBBBBCCBCCCCCCCCCCBCCCBBCBBBBBBBBCCBCBBBBBBBBBBBBBBBBCCBCCCCCBBBBCBCCCCCCCCCCCBBCCCCCBBBBBBBBBCCBBBBBCBCCBBBBCCCCCBCCBBBCBBBBBCCBCCCCBBCBBBBBBBBBBCBBBCCBCCCCCCCC...
result:
ok good plan!
Subtask #13:
score: 6
Accepted
Test #13:
score: 6
Accepted
time: 59ms
memory: 29900kb
input:
16
output:
BCBBCCCCBBBBBBCCCCCCCCBBCCCCBBCCBBBBBBCCBBBBBBBBBBCCCCBBCCCCCCCCCCCCCCBBCCCCCCCCCCBBBBCCBBBBBBBBCCCCBBCCCCCCCCCCBBBBBBBBCCBBCCCCBBBBBBCCBBBBBBBBBBCCCCBBCCCCCCCCBBBBCCBBBBBBBBBBBBBBBBBBBBCCBBBBBBCCCCBBCCCCCCCCCCCCCCCCBBBBCCBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBBCCCCCCCCCCBBBBCCBBBBBBBBCCCCBBCCCCCC...
result:
ok good plan!
Subtask #14:
score: 6
Accepted
Test #14:
score: 6
Accepted
time: 146ms
memory: 48844kb
input:
17
output:
BBCCBBBCCCCBCCBCBBBCBBBBBCCBCCCCCCCBCCCCCBBCBBBBCCBCCCCCBBBBCBCCBBBCBBBBBCCBCCCCBBCBBBBBBBBBBCBBBCCBCCCCCCCCBBCBCCCCCCCCCCCCCCCCCCCBCCCCCBBCBBBBCCBCCCCCCCCCCBCCCBBCBBBBBBBBCCBCBBBBBBBBBBBBBBBBCCBCCCCCBBBBCBCCCCCCCCCCCBBCCCCCBBBBBBBBBCCBBBBBCCBCBBBBCCCCCBCCBBBCBBBBBCCBCCCCBBCBBBBBBBBBBCBBBCCBCCCCCCCC...
result:
ok good plan!
Subtask #15:
score: 6
Accepted
Test #15:
score: 6
Accepted
time: 381ms
memory: 97704kb
input:
18
output:
BCBBCCCCBBBBBBCCCCCCCCBBCCCCBBCCBBBBBBCCBBBBBBBBBBCCCCBBCCCCCCCCCCCCCCBBCCCCCCCCCCBBBBCCBBBBBBBBCCCCBBCCCCCCCCCCBBBBBBBBCCBBCCCCBBBBBBCCBBBBBBBBBBCCCCBBCCCCCCCCBBBBCCBBBBBBBBBBBBBBBBBBBBCCBBBBBBCCCCBBCCCCCCCCCCCCCCCCBBBBCCBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBBCCCCCCCCCCBBBBCCBBBBBBBBCCCCBBCCCCCC...
result:
ok good plan!
Extra Test:
score: 0
Extra Test Passed