QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#120936 | #4327. Šeširi | zhouhuanyi# | 100 ✓ | 301ms | 8020kb | C++11 | 1.7kb | 2023-07-07 12:48:55 | 2024-07-04 00:29:03 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cmath>
#define N 18
#define eps 1e-9
using namespace std;
int read()
{
char c=0;
int sum=0;
while (c<'0'||c>'9') c=getchar();
while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
return sum;
}
int n,delta[N+1];
double X[N+1],Y[N+1];
const double Pi=asin(1)*2;
char c[N+1][1<<N];
int main()
{
int cnt,rst,cnt2,d;
double sx,sy;
n=read();
if (n==4||n==5||n==7)
{
for (int i=1;i<=n;++i) X[i]=cos(2*i*Pi/n),Y[i]=sin(2*i*Pi/n);
for (int i=1;i<=n;++i)
for (int j=0;j<(1<<(n-1));++j)
{
sx=sy=cnt=rst=d=0;
for (int k=n;k>=1;--k)
if (i!=k)
delta[k]=(j>>cnt)&1,cnt++;
cnt=1;
for (int k=i+1;k<=n;++k)
{
if (delta[k]) rst++,sx+=X[cnt],sy+=Y[cnt];
cnt++;
}
for (int k=1;k<=i-1;++k)
{
if (delta[k]) rst++,sx+=X[cnt],sy+=Y[cnt];
cnt++;
}
if (abs(sy)<eps) d=abs(sx)>=eps;
else d=(sy<0)^(rst&1);
c[i][j]=(!d)?'B':'C';
}
}
else
{
for (int i=1;i<=n;++i)
for (int j=0;j<(1<<(n-1));++j)
{
sx=sy=cnt=cnt2=d=0;
for (int k=n;k>=1;--k)
if (i!=k)
delta[k]=(j>>cnt)&1,cnt++;
cnt=cnt2=0;
for (int k=1;k<=n;++k)
if (i!=k)
{
if (!delta[k]) cnt++;
else cnt2++;
}
if (cnt<cnt2)
{
rst=i;
for (int k=1;k<=n;++k)
if (i!=k&&!delta[k])
rst+=k+(i<k);
}
else
{
rst=i;
for (int k=1;k<=n;++k)
if (i!=k&&delta[k])
rst+=k+(i<k);
}
c[i][j]=(!(rst&1))?'B':'C';
}
}
for (int i=1;i<=n;++i)
{
for (int j=0;j<(1<<(n-1));++j) printf("%c",c[i][j]);
puts("");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 7
Accepted
Test #1:
score: 7
Accepted
time: 1ms
memory: 3820kb
input:
4
output:
BBCCCBBC BCCBBCBC BCBBCBCC BBCCCBBC
result:
ok good plan!
Subtask #2:
score: 7
Accepted
Test #2:
score: 7
Accepted
time: 1ms
memory: 5852kb
input:
5
output:
BBBCCCCBCCBBBCCC BBCCCBBCBCCBCBCC BCCBBCCCBCBCCBBC BCBCBBCBCBCCCCBC BBBCCCCBCCBBBCCC
result:
ok good plan!
Subtask #3:
score: 7
Accepted
Test #3:
score: 7
Accepted
time: 1ms
memory: 5796kb
input:
6
output:
CBCBBCBBCBCCBBCBBCBBCCBCBBCBBCBC BCBCCBCCBCBBCCBCCBCCBBCBCCBCCBCB CBCBBCBBCBCCBBCBBCBBCCBCBBCBBCBC BCBCCBCCBCBBCCBCCBCCBBCBCCBCCBCB CBCBBCBBCBCCBBCBBCBBCCBCBBCBBCBC BCBCCBCCBCBBCCBCCBCCBBCBCCBCCBCB
result:
ok good plan!
Subtask #4:
score: 7
Accepted
Test #4:
score: 7
Accepted
time: 1ms
memory: 5896kb
input:
7
output:
BBBCBCCBCCCBCBBCCBCBBBBCBCCCCBCBCCCBBBBCBCCCCCCBBCCCCBBBCBBCBCCC BBBCCCCBCCBBBCCCCCBBBCCCBCCBCBBCBCCBCBBCBBBCCCBBCBBCCCCBCCBBBCCC BBCCCBBCCBBCBCCBBCCBBBCBCBCCCBBCBCCBCBCCCBCCCBBCCBBCBCCBBCCBCBCC BCCBCBBCBCBCCCCBBCCCCCCBCBBCBCCCBCBCBCCBCBBBBCBCCBBCBCBCBCCBCBBC BCCBBBCCBCCCCBBCBBBCCBBBCBBBBCCBCBBCCCCB...
result:
ok good plan!
Subtask #5:
score: 7
Accepted
Test #5:
score: 7
Accepted
time: 1ms
memory: 5708kb
input:
8
output:
CBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBC BCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCB CBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCB...
result:
ok good plan!
Subtask #6:
score: 7
Accepted
Test #6:
score: 7
Accepted
time: 1ms
memory: 5648kb
input:
9
output:
CCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCC BBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBCCBBCCBBBBC...
result:
ok good plan!
Subtask #7:
score: 7
Accepted
Test #7:
score: 7
Accepted
time: 0ms
memory: 5608kb
input:
10
output:
CBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCCCBCBBCBCCBCBBCBBBCBCCBCCBCBBCCBCBCBCCBCBBCBCCBCCCBCBBCBBCBCCBBCBBCBCCBCCBCBBCCBCCBCCBBCBCCBCCBCBCBCBBCBCCBCBBCBBBCBCCBCCBCBBCCBCCBCBBCBBCBCCBBCBBCBBCCBCBBCBBCBCBCBCCBCCBCBBCCBCCBCCBBCBCCBCCBCBBCBBCCBCBBCBBCBCCCBCCBCBBCBCCBCBBCBCCBCBBCBCCBCCCBCBBCBBCBCCBBCBBCBCCBCCBCBB...
result:
ok good plan!
Subtask #8:
score: 7
Accepted
Test #8:
score: 7
Accepted
time: 2ms
memory: 5724kb
input:
11
output:
CCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBCCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCBBBCCBBCCCCBBCCBCBBCCBBCBCCBCCBCCBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBCCCBBCCBBBBCCBBCBCCBBCCBCBBCBBCBBBBCCBBCCCCBBCCBCBBCCBBCBCCBCCBCCCCBBCCBCBBCBBCBBCCBCCBCCBCBBCCBBCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCBBBCCBBCCCCBB...
result:
ok good plan!
Subtask #9:
score: 7
Accepted
Test #9:
score: 7
Accepted
time: 4ms
memory: 5728kb
input:
12
output:
CBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBC...
result:
ok good plan!
Subtask #10:
score: 7
Accepted
Test #10:
score: 7
Accepted
time: 7ms
memory: 7768kb
input:
13
output:
CCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCBBCCBBCCCCBB...
result:
ok good plan!
Subtask #11:
score: 6
Accepted
Test #11:
score: 6
Accepted
time: 15ms
memory: 5796kb
input:
14
output:
CBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBBBCBCCBCBBCBCCBCCCBCBBCBBCBCCBBCBBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBC...
result:
ok good plan!
Subtask #12:
score: 6
Accepted
Test #12:
score: 6
Accepted
time: 32ms
memory: 5852kb
input:
15
output:
CCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCBCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCBBCCBBCCCCBB...
result:
ok good plan!
Subtask #13:
score: 6
Accepted
Test #13:
score: 6
Accepted
time: 64ms
memory: 5924kb
input:
16
output:
CBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBC...
result:
ok good plan!
Subtask #14:
score: 6
Accepted
Test #14:
score: 6
Accepted
time: 133ms
memory: 7768kb
input:
17
output:
CCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCCCBBCCBBBBCCBBCCBBCCBBCCCCBB...
result:
ok good plan!
Subtask #15:
score: 6
Accepted
Test #15:
score: 6
Accepted
time: 301ms
memory: 8020kb
input:
18
output:
CBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBCBCBCCBCBBCBC...
result:
ok good plan!
Extra Test:
score: 0
Extra Test Passed