(1) Each conversion column can appear three times at most, because if it appears four times, it is equivalent to turning a circle, equal to 0. There are a total of 4 ^ 9 cases, which can be traversed.
For example:
- Void DFS (INT clocks [])
- {
- For (INT I1 = 0; I1 <4; I1 ++)
- For (INT I2 = 0; I2 <4; I2 ++)
- For (INT I3 = 0; I3 <4; I3 ++)
- For (INT I4 = 0; I4 <4; I4 ++)
- For (INT I5 = 0; I5 <4; I5 ++)
- For (INT I6 = 0; I6 <4; I6 ++)
- For (INT i7 = 0; i7 <4; i7 ++)
- For (INT i8 = 0; i8 <4; i8 ++)
- For (INT I9 = 0; I9 <4; I9 ++)
- {Int means [9] = {I1, I2, I3, I4, I5, I6, i7, i8, I9}; If (is (clocks, means ))
- {Int last; For (INT I = 8; I>-1; I --) if (means [I]! = 0) {last = I; break;} For (INT I = 0; I <last;
- I ++) while (means [I]! = 0) {fout <I + 1 <''; -- means [I];}
- While (means [last]> 1) {fout <last + 1 <''; -- means [last];} fout <last + 1 <Endl ;}
- }
- }
(2) I originally wanted to use BFs, and the result code only passed the first two test data, 3rd of which seriously timed out on my computer ~ It has been running for N years ~ The efficiency is too low. Because the number of nodes to be convenient increases by 9 ^ N, the third test data (the answer is 11 digits) will stop.
(3) I finally used the Internet to facilitate space solution based on different situations.