QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#124630 | #4327. Šeširi | He_Ren | 0 | 27ms | 15216kb | C++17 | 1.3kb | 2023-07-15 11:27:10 | 2023-07-15 11:27:13 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define bbit(i) (1<<(i))
#define bdig(x,i) (((x)>>(i))&1)
int getdel(int mask,int i)
{
int t = mask >> (i+1);
return mask ^ (t << (i+1)) ^ (t << i);
}
vector< vector<int> > getres(int n)
{
if(n == 2) return {{0,1}, {1,0}};
auto a = getres(n - 2);
vector< vector<int> > res(n, vector<int>(1 << (n-1)));
for(int i=0; i<n-2; ++i)
for(int mask=0; mask<(1<<(n-1)); ++mask)
{
res[i][mask] = a[i][mask & (bbit(n-3) - 1)];
if(bdig(mask,n-2) != bdig(mask,n-1) && bdig(mask,n-1) == 0)
res[i][mask] ^= 1;
}
for(int mask=0; mask<(1<<(n-1)); ++mask)
{
int cnt = 0, ok = 0;
for(int i=0; i<n-2; ++i)
if(bdig(mask, i) == 0)
{
++cnt;
int tmask = mask & (bbit(n-2) - 1);
if(a[i][getdel(tmask, i)] == 0)
++ok;
}
int flag = cnt % 2 == 1 && ok == cnt / 2;
res[n-2][mask] = bdig(mask,n-2) ^ flag;
res[n-1][mask] = bdig(mask,n-2) ^ 1 ^ flag;
}
return res;
}
int main(void)
{
int n;
scanf("%d",&n);
auto ans = getres(n);
reverse(ans.begin(), ans.end());
for(int i=0; i<n; ++i, printf("\n"))
{
for(int j=0; j<(1<<(n-1)); ++j)
putchar(ans[i][j] + 'B');
}
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3628kb
input:
4
output:
CCBCBBCB BBCBCCBC CBCBBCBC BCBCCBCB
result:
wrong answer your plan fails on CCCB
Subtask #2:
score: 0
Memory Limit Exceeded
Test #2:
score: 0
Memory Limit Exceeded
input:
5
output:
result:
Subtask #3:
score: 0
Wrong Answer
Test #3:
score: 0
Wrong Answer
time: 2ms
memory: 3632kb
input:
6
output:
CCBCCCCCBCCBCBCCBBCBBBBBCBBCBCBB BBCBBBBBCBBCBCBBCCBCCCCCBCCBCBCC CCBCBBCBCCBCBBCBBBCBCCBCBBCBCCBC BBCBCCBCBBCBCCBCCCBCBBCBCCBCBBCB CBCBBCBCCBCBBCBCBCBCCBCBBCBCCBCB BCBCCBCBBCBCCBCBCBCBBCBCCBCBBCBC
result:
wrong answer your plan fails on CCCBBB
Subtask #4:
score: 0
Memory Limit Exceeded
Test #4:
score: 0
Memory Limit Exceeded
input:
7
output:
result:
Subtask #5:
score: 0
Wrong Answer
Test #5:
score: 0
Wrong Answer
time: 1ms
memory: 3648kb
input:
8
output:
CCBCCCCCBCCBCBCCCCCCCCBCCBCCCCCCBCCBCCCCCCCCBCCBCBCCBCCBCCCCCCBCBBCBBBBBCBBCBCBBBBBBBBCBBCBBBBBBCBBCBBBBBBBBCBBCBCBBCBBCBBBBBBCB BBCBBBBBCBBCBCBBBBBBBBCBBCBBBBBBCBBCBBBBBBBBCBBCBCBBCBBCBBBBBBCBCCBCCCCCBCCBCBCCCCCCCCBCCBCCCCCCBCCBCCCCCCCCBCCBCBCCBCCBCCCCCCBC CCBCCCCCBCCBCBCCBBCBBBBBCBBCBCBBCCBCCCCCBC...
result:
wrong answer your plan fails on CCCBBBBB
Subtask #6:
score: 0
Memory Limit Exceeded
Test #6:
score: 0
Memory Limit Exceeded
input:
9
output:
result:
Subtask #7:
score: 0
Wrong Answer
Test #7:
score: 0
Wrong Answer
time: 0ms
memory: 3596kb
input:
10
output:
CCBCCCCCBCCBCBCCCCCCCCBCCBCCCCCCBCCBCCCCCCCCBCCBCBCCBCCBCCCCCCBCCCCCCCBCCBCCCCCCCCBCCCCCBCCBCBCCCBCCBCCBCCCCCCBCCCCCCBCCCCBCCCCCBCCBCCCCCCCCBCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCBCCCCCCCCBCCBCBCCBCCBCCCCCCBCBCCBCCCCCCCCBCCBCCCCCCBCCBCCCCCCCCBCCCCCBCCBCBCCBBCBBBBBCBBCBCBBBBBBBBCBBCBBBBBBCBBCBBBBBBBB...
result:
wrong answer your plan fails on CCCBBBBBBB
Subtask #8:
score: 0
Memory Limit Exceeded
Test #8:
score: 0
Memory Limit Exceeded
input:
11
output:
result:
Subtask #9:
score: 0
Wrong Answer
Test #9:
score: 0
Wrong Answer
time: 0ms
memory: 3768kb
input:
12
output:
CCBCCCCCBCCBCBCCCCCCCCBCCBCCCCCCBCCBCCCCCCCCBCCBCBCCBCCBCCCCCCBCCCCCCCBCCBCCCCCCCCBCCCCCBCCBCBCCCBCCBCCBCCCCCCBCCCCCCBCCCCBCCCCCBCCBCCCCCCCCBCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCBCCCCCCCCBCCBCBCCBCCBCCCCCCBCBCCBCCCCCCCCBCCBCCCCCCBCCBCCCCCCCCBCCCCCBCCBCBCCCCCCCCBCCBCCCCCCCCBCCCCCBCCBCBCCCBCCBCCBCCCC...
result:
wrong answer your plan fails on CCCBBBBBBBBB
Subtask #10:
score: 0
Memory Limit Exceeded
Test #10:
score: 0
Memory Limit Exceeded
input:
13
output:
result:
Subtask #11:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 0ms
memory: 3960kb
input:
14
output:
CCBCCCCCBCCBCBCCCCCCCCBCCBCCCCCCBCCBCCCCCCCCBCCBCBCCBCCBCCCCCCBCCCCCCCBCCBCCCCCCCCBCCCCCBCCBCBCCCBCCBCCBCCCCCCBCCCCCCBCCCCBCCCCCBCCBCCCCCCCCBCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCBCCCCCCCCBCCBCBCCBCCBCCCCCCBCBCCBCCCCCCCCBCCBCCCCCCBCCBCCCCCCCCBCCCCCBCCBCBCCCCCCCCBCCBCCCCCCCCBCCCCCBCCBCBCCCBCCBCCBCCCC...
result:
wrong answer your plan fails on CCCBBBBBBBBBBB
Subtask #12:
score: 0
Memory Limit Exceeded
Test #12:
score: 0
Memory Limit Exceeded
input:
15
output:
result:
Subtask #13:
score: 0
Wrong Answer
Test #13:
score: 0
Wrong Answer
time: 4ms
memory: 6064kb
input:
16
output:
CCBCCCCCBCCBCBCCCCCCCCBCCBCCCCCCBCCBCCCCCCCCBCCBCBCCBCCBCCCCCCBCCCCCCCBCCBCCCCCCCCBCCCCCBCCBCBCCCBCCBCCBCCCCCCBCCCCCCBCCCCBCCCCCBCCBCCCCCCCCBCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCBCCCCCCCCBCCBCBCCBCCBCCCCCCBCBCCBCCCCCCCCBCCBCCCCCCBCCBCCCCCCCCBCCCCCBCCBCBCCCCCCCCBCCBCCCCCCCCBCCCCCBCCBCBCCCBCCBCCBCCCC...
result:
wrong answer your plan fails on CCCBBBBBBBBBBBBB
Subtask #14:
score: 0
Memory Limit Exceeded
Test #14:
score: 0
Memory Limit Exceeded
input:
17
output:
result:
Subtask #15:
score: 0
Wrong Answer
Test #15:
score: 0
Wrong Answer
time: 27ms
memory: 15216kb
input:
18
output:
CCBCCCCCBCCBCBCCCCCCCCBCCBCCCCCCBCCBCCCCCCCCBCCBCBCCBCCBCCCCCCBCCCCCCCBCCBCCCCCCCCBCCCCCBCCBCBCCCBCCBCCBCCCCCCBCCCCCCBCCCCBCCCCCBCCBCCCCCCCCBCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCBCCCCCCCCBCCBCBCCBCCBCCCCCCBCBCCBCCCCCCCCBCCBCCCCCCBCCBCCCCCCCCBCCCCCBCCBCBCCCCCCCCBCCBCCCCCCCCBCCCCCBCCBCBCCCBCCBCCBCCCC...
result:
wrong answer your plan fails on CCCBBBBBBBBBBBBBBB