Submission #1604040
Source Code Expand
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def I(): return int(sys.stdin.readline()) def F(): return float(sys.stdin.readline()) def S(): return input() def main(): n = I() a = [[1 if c == '#' else 0 for c in S()] for _ in range(n)] b = [n-sum(a[i]) for i in range(n)] t = 0 for i in range(n): if not all([a[j][i] == 1 for j in range(n)]): t += 1 if min(b) == 0: return t if min(b) == n: return -1 r = min(b) + 1 + t for i in range(n): ai = a[i] for j in range(n): if ai[j] == 0: continue if r > b[j] + t: r = b[j] + t return r print(main())
Submission Info
Submission Time | |
---|---|
Task | B - Row to Column |
User | iehn |
Language | Python (3.4.3) |
Score | 1300 |
Code Size | 1133 Byte |
Status | AC |
Exec Time | 100 ms |
Memory | 7588 KB |
Judge Result
Set Name | Sample | Subtask | All | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | 1000 / 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 | 80 ms | 6812 KB |
0_01.txt | AC | 41 ms | 5408 KB |
0_02.txt | AC | 41 ms | 5412 KB |
0_03.txt | AC | 41 ms | 5408 KB |
0_04.txt | AC | 42 ms | 5404 KB |
1_00.txt | AC | 41 ms | 5412 KB |
1_01.txt | AC | 41 ms | 5408 KB |
1_02.txt | AC | 41 ms | 5404 KB |
1_03.txt | AC | 41 ms | 5408 KB |
1_04.txt | AC | 41 ms | 5408 KB |
1_05.txt | AC | 41 ms | 5408 KB |
1_06.txt | AC | 41 ms | 5404 KB |
1_07.txt | AC | 41 ms | 5412 KB |
1_08.txt | AC | 41 ms | 5532 KB |
1_09.txt | AC | 41 ms | 5404 KB |
1_10.txt | AC | 41 ms | 5404 KB |
1_11.txt | AC | 41 ms | 5412 KB |
1_12.txt | AC | 42 ms | 5404 KB |
1_13.txt | AC | 41 ms | 5408 KB |
1_14.txt | AC | 41 ms | 5404 KB |
2_00.txt | AC | 79 ms | 7584 KB |
2_01.txt | AC | 79 ms | 7588 KB |
2_02.txt | AC | 91 ms | 7580 KB |
2_03.txt | AC | 92 ms | 7580 KB |
2_04.txt | AC | 92 ms | 7584 KB |
2_05.txt | AC | 91 ms | 7584 KB |
2_06.txt | AC | 90 ms | 7588 KB |
2_07.txt | AC | 82 ms | 6948 KB |
2_08.txt | AC | 99 ms | 7584 KB |
2_09.txt | AC | 95 ms | 7584 KB |
2_10.txt | AC | 97 ms | 7584 KB |
2_11.txt | AC | 100 ms | 7580 KB |
2_12.txt | AC | 99 ms | 7580 KB |
2_13.txt | AC | 89 ms | 7076 KB |
2_14.txt | AC | 91 ms | 7456 KB |
2_15.txt | AC | 82 ms | 7068 KB |
2_16.txt | AC | 82 ms | 7196 KB |
2_17.txt | AC | 79 ms | 7076 KB |
2_18.txt | AC | 72 ms | 6812 KB |
2_19.txt | AC | 76 ms | 7580 KB |
2_20.txt | AC | 64 ms | 6816 KB |
2_21.txt | AC | 63 ms | 6688 KB |
2_22.txt | AC | 78 ms | 7580 KB |