QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#121096#4327. Šeširicsy2005100 ✓109ms16176kbC++144.0kb2023-07-07 15:44:072023-07-07 15:44:09

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-07 15:44:09]
  • 评测
  • 测评结果:100
  • 用时:109ms
  • 内存:16176kb
  • [2023-07-07 15:44:07]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<bitset>
#include<cassert>
#include<random>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(((long long)(n))-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();++itr)
#define pb push_back
#define mk make_pair
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define spln(i,n) (i==n?'\n':' ')
#define fac_init(n){fac[0]=fac[1]=inv[1]=fi[0]=fi[1]=1;fz(i,2,n){fac[i]=1ll*fac[i-1]*i%mod;inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;fi[i]=1ll*fi[i-1]*inv[i]%mod;}}
using namespace std;
typedef long long i64;
typedef long double f80;
typedef unsigned int u32;
typedef unsigned long long u64;
//typedef __int128 i128;
//typedef unsigned __int128 u128;
/*#ifndef ONLINE_JUDGE
	FILE *___=freopen("1.in","r",stdin);
#endif*/
inline void read(int &x)
{
	char c;int f=1;
	while(!isdigit(c=getchar()))if(c=='-')f=-1;
	x=(c&15);while(isdigit(c=getchar()))x=(x<<1)+(x<<3)+(c&15);
	x*=f;
}
mt19937 rnd(10641735);
int n,m,i,j,k,a[25];
int rem[1<<18];
vector<vector<int> > solve(int n)
{
	if(n==2){
		vector<vector<int> > f;
		f.push_back((vector<int>){0,1});
		f.push_back((vector<int>){1,0});
		rem[2]=0; // 01
		rem[1]=1; // 10
		return f;
	}
	vector<vector<int> > v=solve(n-2);
	vector<int> tmp((1<<(n-1)),0);
	vector<vector<int> > f(n,tmp);
	int i,j,_;
	for(i=2;i<n;i++){
		int c=0;
		fz0k(j,(1<<(n-3))){
			f[i][j]=v[i-2][j]; // 00
			f[i][j+(1<<(n-3))]=v[i-2][j]; // 10
			f[i][j+(1<<(n-2))]=(1^v[i-2][j]); // 01
			f[i][j+(1<<(n-3))+(1<<(n-2))]=v[i-2][j]; // 11
		}
	}
	fz0k(i,(1<<(n-2))){
		if(__builtin_popcount(i)%2==0){
			f[0][i]=0; // 00 10
			f[0][i+(1<<(n-2))]=1; // 01 11
			f[1][i]=1; // 00 01
			f[1][i+(1<<(n-2))]=0; // 10 11
			rem[i+(1<<(n-1))]=0; // 01
			rem[i+(1<<(n-2))]=1; // 10
		}
		else{
			if(rem[i]==0){
				f[0][i]=0; // 00 10
				f[0][i+(1<<(n-2))]=1; // 01 11
				f[1][i]=1; // 00 01
				f[1][i+(1<<(n-2))]=0; // 10 11
				rem[i]=0; // 00
				rem[i+(1<<(n-1))+(1<<(n-2))]=0; // 11
			}
			else{
				f[0][i]=1; // 00 10
				f[0][i+(1<<(n-2))]=0; // 01 11
				f[1][i]=0; // 00 01
				f[1][i+(1<<(n-2))]=1; // 10 11
				rem[i]=1; // 00
				rem[i+(1<<(n-1))+(1<<(n-2))]=1; // 11
			}
		}
	}
	return f;
}
int main()
{
	/*
	fz0k(a,2)fz0k(b,2)fz0k(c,2)fz0k(d,2){
		fz0k(r01,2)fz0k(r10,2){
			if((a==0)+(c==0)<1) continue; // 00
			if((b==1)+(d==1)<1) continue; // 11
			if((!r01?(b==0):(c==1))<1) continue; // 01
			if((!r10?(d==0):(a==1))<1) continue; // 10
			cerr<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<r01<<' '<<r10<<endl;
		}
	}
	*/
	read(n);
	vector<vector<int> > f=solve(n/2*2);
	if(n%2==1){
		vector<vector<int> > v=f;f.clear();
		vector<int> tmp((1<<(n-1)),0);f.resize(n,tmp);
		fz1(i,n-1){
			fz0k(j,(1<<(n-2))){
				f[i][j]=v[i-1][j];
				f[i][j+(1<<(n-2))]=v[i-1][j];
			}
		}
		fz0k(j,(1<<(n-1))){
			if(__builtin_popcount(j)%2==0){
				f[0][j]=rnd()%2;
			}
			else{
				f[0][j]=!rem[j];
			}
		}
	}
	fz0k(i,(1<<n)){
		int c0=0,c1=0,s0=0,s1=0;
		fz0k(j,n){
			if((i>>j)&1)c1++;else c0++;
			int c=0;
			fz0k(k,n)if(j!=k) c=(c*2+((i>>k)&1));
			if(f[j][c]==((i>>j)&1)){
				if((i>>j)&1)s1++;else s0++;
			}
		}
		if(s0<c0/2||s1<c1/2){
			cerr<<i<<endl;
		}
		if(s0+s1<n/2){
			cerr<<'*'<<i<<endl;
		}
	}
	fz0k(i,n){
		fz0k(j,(1<<(n-1))){
			putchar("BC"[f[i][j]]);
		}
		puts("");
	}
	return 0;
}

详细

Subtask #1:

score: 7
Accepted

Test #1:

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

input:

4

output:

BCBBCBCC
CBCCBCBB
BCBCCBBC
CBCBBCCB

result:

ok good plan!

Subtask #2:

score: 7
Accepted

Test #2:

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

input:

5

output:

BBCBBBCBCBBCBBCC
BCBBCBCCBCBBCBCC
CBCCBCBBCBCCBCBB
BCBCCBBCBCBCCBBC
CBCBBCCBCBCBBCCB

result:

ok good plan!

Subtask #3:

score: 7
Accepted

Test #3:

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

input:

6

output:

BCBBCBBCBBBBBCBBCBCCBCCBCCCCCBCC
CBCCBCCBCCCCCBCCBCBBCBBCBBBBBCBB
BCBBCBCCBCBBCBCCCBCCBCBBBCBBCBCC
CBCCBCBBCBCCBCBBBCBBCBCCCBCCBCBB
BCBCCBBCBCBCCBBCCBCBBCCBBCBCCBBC
CBCBBCCBCBCBBCCBBCBCCBBCCBCBBCCB

result:

ok good plan!

Subtask #4:

score: 7
Accepted

Test #4:

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

input:

7

output:

BBCBBBCBCBBCBBCCBBBBBBBBBBBBBCCBCCCCBCCBBCCCCBCCCBCCBBBBCCCCBBCC
BCBBCBBCBBBBBCBBCBCCBCCBCCCCCBCCBCBBCBBCBBBBBCBBCBCCBCCBCCCCCBCC
CBCCBCCBCCCCCBCCBCBBCBBCBBBBBCBBCBCCBCCBCCCCCBCCBCBBCBBCBBBBBCBB
BCBBCBCCBCBBCBCCCBCCBCBBBCBBCBCCBCBBCBCCBCBBCBCCCBCCBCBBBCBBCBCC
CBCCBCBBCBCCBCBBBCBBCBCCCBCCBCBBCBCCBCBB...

result:

ok good plan!

Subtask #5:

score: 7
Accepted

Test #5:

score: 7
Accepted
time: 0ms
memory: 3476kb

input:

8

output:

BCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBCCBCCBCCCCCBCCBCCBCBBCCBBCBCCBCCCCCCCCCCCCCCCCCBCCBCCBCCCCCBCC
CBCCBCCBCCCCCBCCBCCBCBBCCBBCBCCBCCCCCCCCCCCCCCCCCBCCBCCBCCCCCBCCBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBB
BCBBCBBCBBBBBCBBCBCCBCCBCCCCCBCCBCBBCBBCBB...

result:

ok good plan!

Subtask #6:

score: 7
Accepted

Test #6:

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

input:

9

output:

BBCBBBCBCBBCBBCCBBBBBBBBBBBBBCCBCCCCBCCBBCCCCBCCCBCCBBBBCCCCBBCCBBCBBBBCBBBBBBCBCBBCBCCBBBBBCBBBCBBBBCCBBCCBCBBBBCCBCBBBCBBCBCBBCCBCBCCCCCCBCBCCCCCBCCBCCBCCBCCBCCCBCBCCCBBCCCCBCBBCCCCBBCCCCCCCCBCCBCBBCBBCCBCBBCCBBBBBBBBCBCBBCCBCCCCCCCCBCCCCBBCCBBCBCBCCBBCB
BCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBB...

result:

ok good plan!

Subtask #7:

score: 7
Accepted

Test #7:

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

input:

10

output:

BCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBCCBCCBCCCCCBCCBCCBCBBCCBBCBCCBCCCCCCCCCCCC...

result:

ok good plan!

Subtask #8:

score: 7
Accepted

Test #8:

score: 7
Accepted
time: 0ms
memory: 3540kb

input:

11

output:

BBCBBBCBCBBCBBCCBBBBBBBBBBBBBCCBCCCCBCCBBCCCCBCCCBCCBBBBCCCCBBCCBBCBBBBCBBBBBBCBCBBCBCCBBBBBCBBBCBBBBCCBBCCBCBBBBCCBCBBBCBBCBCBBCCBCBCCCCCCBCBCCCCCBCCBCCBCCBCCBCCCBCBCCCBBCCCCBCBBCCCCBBCCCCCCCCBCCBCBBCBBCCBCBBCCBBBBBBBBCBCBBCCBCCCCCCCCBCCCCBBCCBBCBCBCCBBCBBCBBCBBCCBBBBCCBCBBCBCBBBBBBBBBBBBBCBBCBBBBB...

result:

ok good plan!

Subtask #9:

score: 7
Accepted

Test #9:

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

input:

12

output:

BCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBBCCBCBBCCBBC...

result:

ok good plan!

Subtask #10:

score: 7
Accepted

Test #10:

score: 7
Accepted
time: 3ms
memory: 3584kb

input:

13

output:

BBCBBBCBCBBCBBCCBBBBBBBBBBBBBCCBCCCCBCCBBCCCCBCCCBCCBBBBCCCCBBCCBBCBBBBCBBBBBBCBCBBCBCCBBBBBCBBBCBBBBCCBBCCBCBBBBCCBCBBBCBBCBCBBCCBCBCCCCCCBCBCCCCCBCCBCCBCCBCCBCCCBCBCCCBBCCCCBCBBCCCCBBCCCCCCCCBCCBCBBCBBCCBCBBCCBBBBBBBBCBCBBCCBCCCCCCCCBCCCCBBCCBBCBCBCCBBCBBCBBCBBCCBBBBCCBCBBCBCBBBBBBBBBBBBBCBBCBBBBB...

result:

ok good plan!

Subtask #11:

score: 6
Accepted

Test #11:

score: 6
Accepted
time: 5ms
memory: 3792kb

input:

14

output:

BCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBBCCBCBBCCBBC...

result:

ok good plan!

Subtask #12:

score: 6
Accepted

Test #12:

score: 6
Accepted
time: 10ms
memory: 4640kb

input:

15

output:

BBCBBBCBCBBCBBCCBBBBBBBBBBBBBCCBCCCCBCCBBCCCCBCCCBCCBBBBCCCCBBCCBBCBBBBCBBBBBBCBCBBCBCCBBBBBCBBBCBBBBCCBBCCBCBBBBCCBCBBBCBBCBCBBCCBCBCCCCCCBCBCCCCCBCCBCCBCCBCCBCCCBCBCCCBBCCCCBCBBCCCCBBCCCCCCCCBCCBCBBCBBCCBCBBCCBBBBBBBBCBCBBCCBCCCCCCCCBCCCCBBCCBBCBCBCCBBCBBCBBCBBCCBBBBCCBCBBCBCBBBBBBBBBBBBBCBBCBBBBB...

result:

ok good plan!

Subtask #13:

score: 6
Accepted

Test #13:

score: 6
Accepted
time: 17ms
memory: 5884kb

input:

16

output:

BCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBBCCBCBBCCBBC...

result:

ok good plan!

Subtask #14:

score: 6
Accepted

Test #14:

score: 6
Accepted
time: 40ms
memory: 9968kb

input:

17

output:

BBCBBBCBCBBCBBCCBBBBBBBBBBBBBCCBCCCCBCCBBCCCCBCCCBCCBBBBCCCCBBCCBBCBBBBCBBBBBBCBCBBCBCCBBBBBCBBBCBBBBCCBBCCBCBBBBCCBCBBBCBBCBCBBCCBCBCCCCCCBCBCCCCCBCCBCCBCCBCCBCCCBCBCCCBBCCCCBCBBCCCCBBCCCCCCCCBCCBCBBCBBCCBCBBCCBBBBBBBBCBCBBCCBCCCCCCCCBCCCCBBCCBBCBCBCCBBCBBCBBCBBCCBBBBCCBCBBCBCBBBBBBBBBBBBBCBBCBBBBB...

result:

ok good plan!

Subtask #15:

score: 6
Accepted

Test #15:

score: 6
Accepted
time: 109ms
memory: 16176kb

input:

18

output:

BCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBBCCBCBBCCBBC...

result:

ok good plan!

Extra Test:

score: 0
Extra Test Passed