QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#120976 | #4327. Šeširi | csy2005 | 7 | 4ms | 15856kb | C++14 | 3.0kb | 2023-07-07 13:08:57 | 2023-07-07 13:08:59 |
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]=1;
rem[1]=0;
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(_,4)fz0k(j,(1<<(n-3))){
f[i][c++]=v[i-2][j];
}
}
fz0k(i,(1<<(n-2))){
if(__builtin_popcount(i)==2){
f[0][i]=0;
f[0][i+(1<<(n-2))]=1;
f[1][i]=1;
f[1][i+(1<<(n-2))]=0;
rem[i+(1<<(n-1))]=1;
rem[i+(1<<(n-2))]=0;
}
else{
if(rem[i]==0){
f[0][i]=0;
f[0][i+(1<<(n-2))]=0;
f[1][i]=1;
f[1][i+(1<<(n-2))]=0;
rem[i]=0;
rem[i+(1<<(n-1))+(1<<(n-2))]=0;
}
else{
f[0][i]=1;
f[0][i+(1<<(n-2))]=1;
f[1][i]=1;
f[1][i+(1<<(n-2))]=0;
rem[i]=1;
rem[i+(1<<(n-1))+(1<<(n-2))]=1;
}
}
}
return f;
}
int main()
{
read(n);
if(n==4){
fz0k(i,(1<<3))if(i&4)putchar('C');else putchar('B');puts("");
fz0k(i,(1<<3))if(i&2)putchar('C');else putchar('B');puts("");
fz0k(i,(1<<3))if(i&4)putchar('C');else putchar('B');puts("");
fz0k(i,(1<<3))if(__builtin_popcount(i)&1)putchar('C');else putchar('B');puts("");
return 0;
}
vector<vector<int> > f=solve(n);
fz0k(i,n){
fz0k(j,(1<<(n-1))){
putchar("BC"[f[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: 3388kb
input:
4
output:
BBBBCCCC BBCCBBCC BBBBCCCC BCCBCBBC
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: 0
Wrong Answer
Test #3:
score: 0
Wrong Answer
time: 1ms
memory: 3388kb
input:
6
output:
BBCBBBBBBBBCBBCBBBCCBCCBBCCCCBCB CCCCCCCCCCCCCCCCBBBBBBBBBBBBBBBB BBCBBBCCBBCBBBCCBBCBBBCCBBCBBBCC CCCCBBBBCCCCBBBBCCCCBBBBCCCCBBBB BCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBC CBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCB
result:
wrong answer your plan fails on CCBBBB
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: 0ms
memory: 3456kb
input:
8
output:
BBCBBBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBCBCCBBCCBCBBBBBCBBBBBBBBCBBCBBBCCBCCBBCCCCBCBBCCBCBBBCBBBBBBBBCCCCCCBCCCBCBBBCBCBBBBBBBBCBBCB CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB BBCBBBBBBBBCBBCBBBCCBCCBBCCCCBCBBBCBBBBBBB...
result:
wrong answer your plan fails on CCBBBBBB
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: 1ms
memory: 3432kb
input:
10
output:
BBCBBBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBCBCCBBCCBCBBBBBCBBBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBCCBBCCBCBBBBCCBCBBBCBBBBBBBBCCBCBBBCBBBBBBBCBBBBBBBBBBBBBBBBBCBBBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBCBCCBBCCBCBBBBBCBBBBBBBBCBBCBBBCCBCCBBCCCCBCBBCCBCBBBCBBBBBBBBCCCCCCBCCCB...
result:
wrong answer your plan fails on CCBBBBBBBB
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: 1ms
memory: 3516kb
input:
12
output:
BBCBBBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBCBCCBBCCBCBBBBBCBBBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBCCBBCCBCBBBBCCBCBBBCBBBBBBBBCCBCBBBCBBBBBBBCBBBBBBBBBBBBBBBBBCBBBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBCBCCBBCCBCBBBBBCBBBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
result:
wrong answer your plan fails on CCBBBBBBBBBB
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: 2ms
memory: 3768kb
input:
14
output:
BBCBBBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBCBCCBBCCBCBBBBBCBBBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBCCBBCCBCBBBBCCBCBBBCBBBBBBBBCCBCBBBCBBBBBBBCBBBBBBBBBBBBBBBBBCBBBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBCBCCBBCCBCBBBBBCBBBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
result:
wrong answer your plan fails on CCBBBBBBBBBBBB
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: 2ms
memory: 5856kb
input:
16
output:
BBCBBBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBCBCCBBCCBCBBBBBCBBBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBCCBBCCBCBBBBCCBCBBBCBBBBBBBBCCBCBBBCBBBBBBBCBBBBBBBBBBBBBBBBBCBBBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBCBCCBBCCBCBBBBBCBBBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
result:
wrong answer your plan fails on CCBBBBBBBBBBBBBB
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: 4ms
memory: 15856kb
input:
18
output:
BBCBBBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBCBCCBBCCBCBBBBBCBBBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCBCCBBCCBCBBBBCCBCBBBCBBBBBBBBCCBCBBBCBBBBBBBCBBBBBBBBBBBBBBBBBCBBBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBCBCCBBCCBCBBBBBCBBBBBBBBCBBCBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
result:
wrong answer your plan fails on CCBBBBBBBBBBBBBBBB