QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#124631#4327. ŠeširiHe_Ren53 19ms15180kbC++171.3kb2023-07-15 11:29:212023-07-15 11:29:24

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-15 11:29:24]
  • 评测
  • 测评结果:53
  • 用时:19ms
  • 内存:15180kb
  • [2023-07-15 11:29:21]
  • 提交

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-3) != bdig(mask,n-2) && bdig(mask,n-2) == 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: 7
Accepted

Test #1:

score: 7
Accepted
time: 1ms
memory: 3580kb

input:

4

output:

CCBCBBCB
BBCBCCBC
CBBCCBCB
BCCBBCBC

result:

ok good plan!

Subtask #2:

score: 0
Memory Limit Exceeded

Test #2:

score: 0
Memory Limit Exceeded

input:

5

output:


result:


Subtask #3:

score: 7
Accepted

Test #3:

score: 7
Accepted
time: 1ms
memory: 3580kb

input:

6

output:

CCBCCCCCBCCBCCBCBBCBBBBBCBBCBBCB
BBCBBBBBCBBCBBCBCCBCCCCCBCCBCCBC
CCBCBBCBBBCBCCBCCCBCBBCBCCBCBBCB
BBCBCCBCCCBCBBCBBBCBCCBCBBCBCCBC
CBBCCBCBBCCBBCBCCBBCCBCBCBBCCBCB
BCCBBCBCCBBCCBCBBCCBBCBCBCCBBCBC

result:

ok good plan!

Subtask #4:

score: 0
Memory Limit Exceeded

Test #4:

score: 0
Memory Limit Exceeded

input:

7

output:


result:


Subtask #5:

score: 7
Accepted

Test #5:

score: 7
Accepted
time: 1ms
memory: 3572kb

input:

8

output:

CCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCCBCCCCCBCCBCCBCBBCBBBBBCBBCBBCBBBBBBBBBBBBBBBBBCBBCBCCBBCCBCBBCBBCBBBBBCBBCBBCB
BBCBBBBBCBBCBBCBBBBBBBBBBBBBBBBBCBBCBCCBBCCBCBBCBBCBBBBBCBBCBBCBCCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCCBCCCCCBCCBCCBC
CCBCCCCCBCCBCCBCBBCBBBBBCBBCBBCBBBCBBBBBCB...

result:

ok good plan!

Subtask #6:

score: 0
Memory Limit Exceeded

Test #6:

score: 0
Memory Limit Exceeded

input:

9

output:


result:


Subtask #7:

score: 7
Accepted

Test #7:

score: 7
Accepted
time: 1ms
memory: 3628kb

input:

10

output:

CCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBCCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCCBCCCCCBCCBCCBCBBCBBBBBCBBCBBCBBBBBBBBBBBBBBBBBCBBCBCCBBCCB...

result:

ok good plan!

Subtask #8:

score: 0
Memory Limit Exceeded

Test #8:

score: 0
Memory Limit Exceeded

input:

11

output:


result:


Subtask #9:

score: 7
Accepted

Test #9:

score: 7
Accepted
time: 2ms
memory: 3760kb

input:

12

output:

CCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBCCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok good plan!

Subtask #10:

score: 0
Memory Limit Exceeded

Test #10:

score: 0
Memory Limit Exceeded

input:

13

output:


result:


Subtask #11:

score: 6
Accepted

Test #11:

score: 6
Accepted
time: 3ms
memory: 3944kb

input:

14

output:

CCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBCCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok good plan!

Subtask #12:

score: 0
Memory Limit Exceeded

Test #12:

score: 0
Memory Limit Exceeded

input:

15

output:


result:


Subtask #13:

score: 6
Accepted

Test #13:

score: 6
Accepted
time: 8ms
memory: 6056kb

input:

16

output:

CCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBCCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok good plan!

Subtask #14:

score: 0
Memory Limit Exceeded

Test #14:

score: 0
Memory Limit Exceeded

input:

17

output:


result:


Subtask #15:

score: 6
Accepted

Test #15:

score: 6
Accepted
time: 19ms
memory: 15180kb

input:

18

output:

CCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBCCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCBCCBCBBCCBBCBCCBCCBCCCCCBCCBCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok good plan!