Submission #19475445
Source Code Expand
Copy
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------
int N;
int C[9][512][512];
int D[256][256];
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>N;
if(N==1) {
cout<<1<<endl;
cout<<"AB"<<endl;
return;
}
C[1][0][0]=0;
C[1][0][1]=1;
for(i=2;i<=N;i++) {
FOR(x,1<<i) C[i][0][x]=x;
int s=1<<(i-2);
FOR(x,((1<<i)-2)) {
FOR(y,s) {
C[i][x*2+1][y]=C[i][x*2+2][y]=C[i-1][x][y];
C[i][x*2+1][y+2*s]=C[i][x*2+2][y+2*s]=C[i-1][x][y+s];
C[i][x*2+1][y+s]=C[i][x*2+2][y+3*s]=C[i-1][x][y]+2*s;
C[i][x*2+1][y+3*s]=C[i][x*2+2][y+s]=C[i-1][x][y+s]+2*s;
}
}
/*
cout<<i<<endl;
FOR(x,(1<<i)-1) {
FOR(y,(1<<i)) cout<<C[i][x][y]<<" ";
cout<<endl;
}
*/
}
cout<<((1<<N)-1)<<endl;
FOR(i,((1<<N)-1)) {
string S;
S.resize(1<<N);
int t=(1<<N)/2;
FOR(x,t) S[C[N][i][x]]='A';
FOR(x,t) S[C[N][i][x+t]]='B';
cout<<S<<endl;
}
/*
FOR(i,(1<<N)-1) {
int t=(1<<N)/2;
FOR(x,t) FOR(y,t) D[C[N][i][x]][C[N][i][y]]++;
FOR(x,t) FOR(y,t) D[C[N][i][x+t]][C[N][i][y+t]]++;
}
FOR(y,1<<N) {
FOR(x,1<<N) _P("%3d ",D[y][x]);
_P("\n");
}
*/
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
cout.tie(0); solve(); return 0;
}
Submission Info
Submission Time |
|
Task |
D - Choosing Up Sides |
User |
kmjp |
Language |
C++ (GCC 9.2.1) |
Score |
700 |
Code Size |
1924 Byte |
Status |
AC |
Exec Time |
9 ms |
Memory |
5572 KB |
Compile Error
./Main.cpp: In function ‘void solve()’:
./Main.cpp:22:8: warning: unused variable ‘j’ [-Wunused-variable]
22 | int i,j,k,l,r,x,y; string s;
| ^
./Main.cpp:22:10: warning: unused variable ‘k’ [-Wunused-variable]
22 | int i,j,k,l,r,x,y; string s;
| ^
./Main.cpp:22:12: warning: unused variable ‘l’ [-Wunused-variable]
22 | int i,j,k,l,r,x,y; string s;
| ^
./Main.cpp:22:14: warning: unused variable ‘r’ [-Wunused-variable]
22 | int i,j,k,l,r,x,y; string s;
| ^
./Main.cpp: In function ‘int main(int, char**)’:
./Main.cpp:6:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
6 | #define FOR(x,to) for(x=0;x<(to);x++)
| ^
./Main.cpp:81:38: note: in expansion of macro ‘FOR’
81 | FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
| ^~~
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
700 / 700 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample_01.txt |
All |
random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, sample_01.txt |
Case Name |
Status |
Exec Time |
Memory |
random_01.txt |
AC |
2 ms |
3596 KB |
random_02.txt |
AC |
2 ms |
3600 KB |
random_03.txt |
AC |
2 ms |
3540 KB |
random_04.txt |
AC |
2 ms |
3648 KB |
random_05.txt |
AC |
4 ms |
3816 KB |
random_06.txt |
AC |
5 ms |
4056 KB |
random_07.txt |
AC |
5 ms |
4484 KB |
random_08.txt |
AC |
9 ms |
5572 KB |
sample_01.txt |
AC |
2 ms |
3436 KB |