QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#120713 | #4327. Šeširi | youngsystem# | 100 ✓ | 414ms | 343816kb | C++20 | 2.2kb | 2023-07-07 10:18:08 | 2024-05-26 01:48:02 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
int n=0,f=1,ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
n=n*10+ch-'0';
ch=getchar();
}
return n*f;
}
vector<int>v[1000005];
int bu[10000005],bv[10000005],fx[10000005],vis[10000005],cnt;
bool visd[2000005];
int now[1000005];
void dfs(int x)
{
visd[x]=true;
for(int i=now[x];i<v[x].size();i=now[x])
{
if(vis[v[x][i]])
{
now[x]=i+1;
continue;
}
vis[v[x][i]]=true;
now[x]=i+1;
if(x==bu[v[x][i]])fx[v[x][i]]=0;
else fx[v[x][i]]=1;
int sth=bu[v[x][i]]+bv[v[x][i]]-x;
dfs(sth);
}
}
int qans[20][500005];
int main()
{
int n;
n=read();
for(int i=0;i<(1<<n);i++)
{
for(int j=1;j<=n;j++)
{
if(i&(1<<(j-1)))continue;
cnt++;
bu[cnt]=2*i;
bv[cnt]=2*(i^(1<<(j-1)))+1;
v[bu[cnt]].push_back(cnt);
v[bv[cnt]].push_back(cnt);
}
}
for(int i=0;i<2*(1<<n);i++)
{
int sth=(int)v[i].size();
if(sth%2==1)
{
cnt++;
bu[cnt]=i;
bv[cnt]=2*(1<<n);
v[bu[cnt]].push_back(cnt);
v[bv[cnt]].push_back(cnt);
}
}
for(int i=0;i<=2*(1<<n);i++)
{
if(!visd[i])dfs(i);
}
for(int i=1;i<=cnt;i++)
{
if(bv[i]==2*(1<<n))continue;
int bh=-1;
for(int j=1;j<=n;j++)
{
if((bu[i]^bv[i])&(1<<j))
{
bh=j;
break;
}
}
int sy=0;
for(int j=1;j<=n;j++)
{
if(j==bh)continue;
int now=0;
if((bu[i])&(1<<j))now=1;
sy=sy*2+now;
}
if(fx[i]==0)qans[bh][sy]=0;
else qans[bh][sy]=1;
}
for(int i=1;i<=n;i++)
{
for(int j=0;j<(1<<(n-1));j++)
{
if(qans[i][j])printf("C");
else printf("B");
}
printf("\n");
}
return 0;
for(int i=0;i<(1<<n);i++)
{
int z0=0,z1=0;
for(int j=1;j<=n;j++)
{
if(i&(1<<(j-1)))z1++;
else z0++;
}
int d0=0,d1=0;
for(int j=1;j<=n;j++)
{
int sth=0;
for(int k=1;k<=n;k++)
{
if(k==j)continue;
if(i&(1<<(k-1)))sth=sth*2+1;
else sth=sth*2;
}
int ans=0;
if(i&(1<<(j-1)))ans=1;
if(qans[j][sth]==0&&ans==0)d0++;
if(qans[j][sth]==1&&ans==1)d1++;
}
if(d0<z0/2||d1<z1/2)
{
printf("wa %d %d %d %d %d\n",i,d0,z0,d1,z1);
return 0;
}
}
printf("ac\n");
return 0;
}
詳細信息
Subtask #1:
score: 7
Accepted
Test #1:
score: 7
Accepted
time: 0ms
memory: 15928kb
input:
4
output:
BCBCCBCC CBCBBCBB BCBCCBCC CBCBBCBB
result:
ok good plan!
Subtask #2:
score: 7
Accepted
Test #2:
score: 7
Accepted
time: 4ms
memory: 20088kb
input:
5
output:
BBCBBBBCCBBBBBCB BCBCCBCBBCBCCCBC CBCBBCBCCBCBBBCB BCBCCBCCBCBBCCBC CBCBBCBBCBCCBBCB
result:
ok good plan!
Subtask #3:
score: 7
Accepted
Test #3:
score: 7
Accepted
time: 5ms
memory: 22200kb
input:
6
output:
BCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCC CBCBBCBBCCBCBCCBBCBBCBBCBBCBBCBB BCBCCBCCBCBBCBBCCBCCBCCBCCBCCBCC CBCBBCBBCCBCBBCBBCBBCCBCBBCBBCBB BCBCCBCCBBCCCCBCCBCCBCCBCCBCCBCC CBCBBCBBCCBBBBCBBCBBCBBCBBCBBCBB
result:
ok good plan!
Subtask #4:
score: 7
Accepted
Test #4:
score: 7
Accepted
time: 4ms
memory: 22180kb
input:
7
output:
BBCBBBBCCBBBBBCBBBBCBCBBBBBBBBBCCBBBBBCBBCCBCBBBBBCBBBBCCBBBBBCB BCBCCBCBBBBCCCBCCBCBBBCBCCCCCBCBBCBCCCBCBBBBBBBCCCBCCCCBBCBCCCBC CBCBBCBBCCCCBCBBBCBCCCBCBBBBBCBCCBCBBBCBCCCCCCCBBBCBBBBCCBCBBBCB BCBCCBCCBCBBCBCCCCCBBBCBCCBCCBCBBCBCCCBCBBCBBBBCCCBCCCCBBCBCCCBC CBCBBCBBCCCCBCBBBBCCCCBCBBCBBCBCCBCBBCBB...
result:
ok good plan!
Subtask #5:
score: 7
Accepted
Test #5:
score: 7
Accepted
time: 0ms
memory: 24376kb
input:
8
output:
BCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCCBBCBBBBBCBCCBBCBCBBCBBCBBBCBCBBCCBCCBCCBCCBCCBCCBCCBCBBCCBBCBCCBCCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCC CBCBBCBBCCBCBCCBBBBBCBBCBBCBBCBBCBBCCCCCBCBBCCBCBCCBCCBCCCBCBCCBBCBBCBBCBBCBBCBBCBBCBBCBBBCBCBBCBBCBBCBBCCBCBCCBBCBBCBBCBBCBBCBB BCBCCBCCBBBBCBBCCBCCBCCBCCBCCBCCBCBBCBBCBB...
result:
ok good plan!
Subtask #6:
score: 7
Accepted
Test #6:
score: 7
Accepted
time: 5ms
memory: 26508kb
input:
9
output:
BBCBBBBCCBBBBBCBBBBCBCBBBCCBCBBCCBBBBBCBBBBBBBBBBBCBCBBCBBBBBCBBBBBCBCBBBBBBBBBBBCBBBBBBCBBBBBBBBBBBBBBBBBBBBBBBBBBCBBBBBBBBBBBCCBBBBBCBBCCBCBBCBBCBCBBCBBBCBCCBBCCBCBBCCBBCBCCBCBBBBCCBBCCBCBBBBBCBBBBCCBBBBBCBBBBCBCBBBBBBBBBCCBBBBBCBBCCBCBBBBBCBBBBCCBBBBBCB BCBCCBCBBBCCCCBCCBCBBBCBCBBCBBCBBBCCBCBBBCC...
result:
ok good plan!
Subtask #7:
score: 7
Accepted
Test #7:
score: 7
Accepted
time: 5ms
memory: 28940kb
input:
10
output:
BCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCCBBCBBBBBCBCCBBCBCBBCBCCBBBCBCBBCCBCCBCCBCCBCCBCCBCCBCCCCCBCCBCCBCCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCCBBCBBBBBCBCCBBCBBBBBBBCBBBCBBBBBCBCCBBCBCBCCCCCCBBCBBBBBCBCCBBCBCBBCBBCBBBCBCBBCBBCBBBBBCBBCBBCBBBCBBBBBCBBCBCCBCBBCBBCBBBCBCBBCCBCCBCCBCCBCCBCCBCCBCBBCCBBCBCCBCCBCCBCCBBCB...
result:
ok good plan!
Subtask #8:
score: 7
Accepted
Test #8:
score: 7
Accepted
time: 0ms
memory: 31356kb
input:
11
output:
BBCBBBBCCBBBBBCBBBBCBCBBBCCBCBBCCBBBBBCBBBBBBBBBBBCBCBBBBBBCBBCBBBBCBCBBBCCBCBBCBCBBBBBCCBBBBCBBBCCBCBBBCBBBBBBBCBBBBBBBBBBBBBBCCBBBBBCBBBBBBBBBBBCBCBBBBBBCBBCBBBBBBBBCBBBCBCCBBBBCBCCBBCCBCBBBBBCBCBBCBBBBBCBBCBBCBBCBBCCBCBBCBBBBBCBBBBBBBBBBBCBBCBBCBBBBBCBBBBBCBCBBBBBBBBBBBCBBBBBCCBBBBCBBBBBBBBBBBBBB...
result:
ok good plan!
Subtask #9:
score: 7
Accepted
Test #9:
score: 7
Accepted
time: 10ms
memory: 35404kb
input:
12
output:
BCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCCBBCBBBBBCBCCBBCBCBBCBCCBBBCBCBBCCBCCBCCBCCBCCBCCBCCBCCCCCBCCBCCBCCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCCBBCBBBBBCBCCBBCBBBBBBCCBBBCBBBBBCBCCBBCBCBCCCCCCBBCBBBBBCBCCBBCBCBBCBBCBBBCBCBBCBBCBCBBCCBBCBCCBBBCBBBBBCBBCBCCBCBBCBCCBBBCBCBBCCBCCBCCBCCBCCBCCBCCBCCCCCBCCBCCBCCBCCBCCBBCB...
result:
ok good plan!
Subtask #10:
score: 7
Accepted
Test #10:
score: 7
Accepted
time: 11ms
memory: 40864kb
input:
13
output:
BBCBBBBCCBBBBBCBBBBCBCBBBCCBCBBCCBBBBBCBBBBBBBBBBBCBCBBBBBBCBBCBBBBCBCBBBCCBCBBCBCBBBBBCCBBBBCBBBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCCBBBBBCBBBBBBBBBBBCBCBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBCBBBBBBCBBCBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBBCBBBBCCBBBBCBBBBBCBCBBBCCBCBBCBCBBBBBCCBBBBCBBBCCBCBBBCBBB...
result:
ok good plan!
Subtask #11:
score: 6
Accepted
Test #11:
score: 6
Accepted
time: 19ms
memory: 50136kb
input:
14
output:
BCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCCBBCBBBBBCBCCBBCBCBBCBCCBBBCBCBBCCBCCBCCBCCBCCBCCBCCBCCCCCBCCBCCBCCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCCBBCBBBBBCBCCBBCBBBBBBCCBBBCBBBBBCBCCBBCBCBCCCCCCBBCBBBBBCBCCBBCBCBBCBBCBBBCBCBBCBBCBCBBCCBBCBCCBBBCBBBBBCBBCBCCBCBBCBCCBBBCBCBBCCBCCBCCBCCBCCBCCBCCBCCCCCBCCBCCBCCBCCBCCBBCB...
result:
ok good plan!
Subtask #12:
score: 6
Accepted
Test #12:
score: 6
Accepted
time: 37ms
memory: 63708kb
input:
15
output:
BBCBBBBCCBBBBBCBBBBCBCBBBCCBCBBCCBBBBBCBBBBBBBBBBBCBCBBBBBBCBBCBBBBCBCBBBCCBCBBCBCBBBBBCCBBBBCBBBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCCBBBBBCBBBBBBBBBBBCBCBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBCBBBBBBCBBCBCBBCBCCBBCCBCBBBBBBBBBBBBBBBBBBCBBCBBBBBCBBCBBCBBBBCBCBBBCCBCBBCBCBBBBBCCBBBBCBBBCCBCBBCCBBC...
result:
ok good plan!
Subtask #13:
score: 6
Accepted
Test #13:
score: 6
Accepted
time: 78ms
memory: 107144kb
input:
16
output:
BCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCCBBCBBBBBCBCCBBCBCBBCBCCBBBCBCBBCCBCCBCCBCCBCCBCCBCCBCCCCCBCCBCCBCCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCCBBCBBBBBCBCCBBCBBBBBBCCBBBCBBBBBCBCCBBCBCBCCCCCCBBCBBBBBCBCCBBCBCBBCBBCBBBCBCBBCBBCBCBBCCBBCBCCBBBCBBBBBCBBCBCCBCBBCBCCBBBCBCBBCCBCCBCCBCCBCCBCCBCCBCCCCCBCCBCCBCCBCCBCCBBCB...
result:
ok good plan!
Subtask #14:
score: 6
Accepted
Test #14:
score: 6
Accepted
time: 204ms
memory: 138316kb
input:
17
output:
BBCBBBBCCBBBBBCBBBBCBCBBBCCBCBBCCBBBBBCBBBBBBBBBBBCBCBBBBBBCBBCBBBBCBCBBBCCBCBBCBCBBBBBCCBBBBCBBBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCCBBBBBCBBBBBBBBBBBCBCBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBCBBBBBBCBBCBCBBCBCCBBCCBCBBBBBBBBBBBBBBBBBBCBBCBBBBBCBBCBBCBBBBCBCBBBCCBCBBCBCBBBBBCCBBBBCBBBCCBCBBCCBBC...
result:
ok good plan!
Subtask #15:
score: 6
Accepted
Test #15:
score: 6
Accepted
time: 414ms
memory: 343816kb
input:
18
output:
BCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCCBBCBBBBBCBCCBBCBCBBCBCCBBBCBCBBCCBCCBCCBCCBCCBCCBCCBCCCCCBCCBCCBCCBCCBCCBBCBCBBCCBCCBCCBCCBCCBCCBBCBBBBBCBCCBBCBBBBBBCCBBBCBBBBBCBCCBBCBCBCCCCCCBBCBBBBBCBCCBBCBCBBCBBCBBBCBCBBCBBCBCBBCCBBCBCCBBBCBBBBBCBBCBCCBCBBCBCCBBBCBCBBCCBCCBCCBCCBCCBCCBCCBCCCCCBCCBCCBCCBCCBCCBBCB...
result:
ok good plan!
Extra Test:
score: 0
Extra Test Passed