QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#121084 | #4327. Šeširi | csy2005 | 53 | 109ms | 16220kb | C++14 | 3.6kb | 2023-07-07 15:37:24 | 2023-07-07 15:37:26 |
Judging History
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>
#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;
}
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);
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: 3432kb
input:
4
output:
BCBBCBCC CBCCBCBB BCBCCBBC CBCBBCCB
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: 3392kb
input:
6
output:
BCBBCBBCBBBBBCBBCBCCBCCBCCCCCBCC CBCCBCCBCCCCCBCCBCBBCBBCBBBBBCBB BCBBCBCCBCBBCBCCCBCCBCBBBCBBCBCC CBCCBCBBCBCCBCBBBCBBCBCCCBCCBCBB BCBCCBBCBCBCCBBCCBCBBCCBBCBCCBBC CBCBBCCBCBCBBCCBBCBCCBBCCBCBBCCB
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: 0ms
memory: 3464kb
input:
8
output:
BCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBCCBCCBCCCCCBCCBCCBCBBCCBBCBCCBCCCCCCCCCCCCCCCCCBCCBCCBCCCCCBCC CBCCBCCBCCCCCBCCBCCBCBBCCBBCBCCBCCCCCCCCCCCCCCCCCBCCBCCBCCCCCBCCBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBB BCBBCBBCBBBBBCBBCBCCBCCBCCCCCBCCBCBBCBBCBB...
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: 3468kb
input:
10
output:
BCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBCCBCCBCCCCCBCCBCCBCBBCCBBCBCCBCCCCCCCCCCCC...
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: 1ms
memory: 3596kb
input:
12
output:
BCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBBCCBCBBCCBBC...
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: 5ms
memory: 3732kb
input:
14
output:
BCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBBCCBCBBCCBBC...
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: 16ms
memory: 5876kb
input:
16
output:
BCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBBCCBCBBCCBBC...
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: 109ms
memory: 16220kb
input:
18
output:
BCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBBCCBCBBCCBBCBCCBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBBBBBBBBBBBBBBBBBCBBCBBCBBBBBCBBCBBCBCCBBCCBCBBCBCCBCBBCCBBCBCCBBCCBCBBCCBBC...
result:
ok good plan!