Submission #1131175
Source Code Expand
n = input() A = ''.join(raw_input() for i in xrange(n)) if n > 5: exit(1) ALL = "#"*(n*n) memo = {} def dfs(state): if state in memo: return memo[state] if state == ALL: return 0 s = list(state) memo[state] = res = 10**9 for i in xrange(n): C = [state[i*n+k] for k in xrange(n)] for j in xrange(n): n_state = s[:] for k in xrange(n): n_state[k*n+j] = C[k] res = min(res, dfs(''.join(n_state))+1) memo[state] = res return res ans = dfs(A) if ans == 10**9: print -1 else: print ans
Submission Info
Submission Time | |
---|---|
Task | B - Row to Column |
User | yaketake08 |
Language | Python (2.7.6) |
Score | 0 |
Code Size | 637 Byte |
Status | RE |
Exec Time | 17 ms |
Memory | 3204 KB |
Judge Result
Set Name | Sample | Subtask | All | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | 0 / 1000 | ||||||||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt |
Subtask | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 2_00.txt, 2_01.txt, 2_02.txt, 2_03.txt, 2_04.txt, 2_05.txt, 2_06.txt, 2_07.txt, 2_08.txt, 2_09.txt, 2_10.txt, 2_11.txt, 2_12.txt, 2_13.txt, 2_14.txt, 2_15.txt, 2_16.txt, 2_17.txt, 2_18.txt, 2_19.txt, 2_20.txt, 2_21.txt, 2_22.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 11 ms | 2696 KB |
0_01.txt | AC | 10 ms | 2696 KB |
0_02.txt | AC | 10 ms | 2696 KB |
0_03.txt | AC | 17 ms | 3072 KB |
0_04.txt | AC | 17 ms | 3076 KB |
1_00.txt | AC | 10 ms | 2696 KB |
1_01.txt | AC | 10 ms | 2692 KB |
1_02.txt | WA | 17 ms | 3076 KB |
1_03.txt | AC | 16 ms | 3076 KB |
1_04.txt | WA | 17 ms | 3076 KB |
1_05.txt | AC | 16 ms | 3072 KB |
1_06.txt | WA | 17 ms | 3076 KB |
1_07.txt | AC | 17 ms | 3072 KB |
1_08.txt | AC | 17 ms | 3076 KB |
1_09.txt | AC | 16 ms | 3072 KB |
1_10.txt | AC | 17 ms | 3076 KB |
1_11.txt | AC | 16 ms | 3076 KB |
1_12.txt | AC | 10 ms | 2696 KB |
1_13.txt | AC | 17 ms | 3076 KB |
1_14.txt | AC | 16 ms | 3072 KB |
2_00.txt | RE | 11 ms | 3204 KB |
2_01.txt | RE | 11 ms | 3204 KB |
2_02.txt | RE | 11 ms | 3204 KB |
2_03.txt | RE | 11 ms | 3204 KB |
2_04.txt | RE | 11 ms | 3204 KB |
2_05.txt | RE | 11 ms | 3204 KB |
2_06.txt | RE | 11 ms | 3204 KB |
2_07.txt | RE | 11 ms | 2948 KB |
2_08.txt | RE | 11 ms | 3204 KB |
2_09.txt | RE | 11 ms | 3204 KB |
2_10.txt | RE | 11 ms | 3204 KB |
2_11.txt | RE | 11 ms | 3204 KB |
2_12.txt | RE | 11 ms | 3204 KB |
2_13.txt | RE | 11 ms | 3076 KB |
2_14.txt | RE | 11 ms | 3076 KB |
2_15.txt | RE | 11 ms | 3076 KB |
2_16.txt | RE | 11 ms | 3076 KB |
2_17.txt | RE | 11 ms | 3076 KB |
2_18.txt | RE | 11 ms | 2948 KB |
2_19.txt | RE | 11 ms | 3204 KB |
2_20.txt | RE | 11 ms | 2948 KB |
2_21.txt | RE | 11 ms | 2948 KB |
2_22.txt | RE | 11 ms | 3204 KB |