report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
ABC string - FlandreOJ: Flandre Online Judge

ABC string

Time limit: 1000 ms
Memory limit: 256 MB
Print all strings of length $n$ consisting of three characters `A`, `B`, and `C`, where no two adjacent characters are the same. For example, the string `ABBC` is not valid because it contains two adjacent `B` characters. ### Input - One line containing an integer $n$. ### Output - Print all valid strings satisfying the condition. The order of printing can be arbitrary. ### Constraints - $1 \le n \le 10$. ### Sample Input: ``` 2 ``` Output: ``` AB BA BC CB AC CA ```
Backtracking
Binary string
ABC string
Subset sum
Subset
Permutations
Group division
Knight's tour
N-queens problem
Maximum path
Knapsack
Build array
Sudoku
Minesweeper
Travelling Salesman Problem
Word search
Topic
Complete Search
Rating 800
Solution (2) Solution