Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int n, maxC, countC;
- char a[102];
- bool check(int n) {
- for (int len=2; len<=n/2; ++len)
- for (int j=n-1; j>=n-len; --j)
- if (a[j]!=a[j-len]) return true;
- return false;
- }
- void _try(int i) {
- if (countC + (n-i)/4 > maxC) return;
- if (i > n) {
- for (int j=0; i<n; ++j) printf("%d ", a[j]);
- return;
- }
- for (char j='A'; j<='C'; ++j) {
- a[i]=j;
- if (check(j)) {
- countC += (j=='C');
- _try(i+1);
- countC -= (j=='C');
- }
- }
- }
- int main() {
- //freopen("xauabc.inp", "r", stdin);
- scanf("%d", &n); maxC=n/4; countC=0;
- _try[1];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment