Submission #8830040
Source Code Expand
import sys input=sys.stdin.readline sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def main(): h, w = MI() s = [[c == "#" for c in input()[:-1]] for _ in range(h)] if w == 2: s = [list(sc) for sc in zip(*s)] h, w = w, h # p2D(s) t = [[-1] * (w - 1) for _ in range(h - 1)] for i in range(h - 1): si = s[i] si1 = s[i + 1] t[i] = [1 - (sum(si[j:j + 2]) + sum(si1[j:j + 2])) % 2 for j in range(w - 1)] # p2D(t) # print() ti=t[0] for i in range(1, h - 1): ti1=ti ti=t[i] for j in range(w - 1): if ti[j]: ti[j] = ti1[j] + 1 # p2D(t) ans = 0 for i in range(h - 1): jtol = [0] * (w - 1) jtor = [0] * (w - 1) ti=t[i] # 高さ、位置の順 stack = [[-1, 0]] for j in range(w - 1): h=ti[j] while stack[-1][0] >= h: stack.pop() jtol[j] = stack[-1][1] stack.append([h, j + 1]) stack = [[-1, w - 1]] for j in range(w - 2, -1, -1): h=ti[j] while stack[-1][0] >= h: stack.pop() jtor[j] = stack[-1][1] stack.append([h, j]) for j in range(w - 1): tmp = (jtor[j] - jtol[j] + 1) * (ti[j] + 1) if tmp > ans: ans = tmp print(ans) main()
Submission Info
Submission Time | |
---|---|
Task | F - Flip and Rectangles |
User | mkawa2 |
Language | Python (3.4.3) |
Score | 0 |
Code Size | 1633 Byte |
Status | TLE |
Exec Time | 2109 ms |
Memory | 95472 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 700 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt, sample3.txt |
All | sample1.txt, sample2.txt, sample3.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 3.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
1.txt | AC | 23 ms | 3444 KB |
10.txt | TLE | 2108 ms | 67444 KB |
11.txt | TLE | 2109 ms | 95472 KB |
12.txt | TLE | 2108 ms | 67444 KB |
13.txt | TLE | 2107 ms | 67444 KB |
14.txt | TLE | 2108 ms | 67572 KB |
15.txt | TLE | 2107 ms | 69368 KB |
16.txt | TLE | 2107 ms | 67444 KB |
17.txt | TLE | 2107 ms | 67444 KB |
18.txt | TLE | 2107 ms | 67444 KB |
19.txt | TLE | 2107 ms | 68984 KB |
2.txt | AC | 22 ms | 3192 KB |
20.txt | TLE | 2108 ms | 67572 KB |
21.txt | TLE | 2107 ms | 67444 KB |
22.txt | TLE | 2108 ms | 67572 KB |
23.txt | TLE | 2108 ms | 67444 KB |
24.txt | TLE | 2107 ms | 69492 KB |
25.txt | TLE | 2108 ms | 67572 KB |
26.txt | TLE | 2108 ms | 67444 KB |
27.txt | TLE | 2108 ms | 67444 KB |
28.txt | TLE | 2107 ms | 69108 KB |
29.txt | TLE | 2108 ms | 67444 KB |
3.txt | TLE | 2108 ms | 67444 KB |
30.txt | TLE | 2108 ms | 67444 KB |
31.txt | TLE | 2108 ms | 67572 KB |
32.txt | TLE | 2108 ms | 67572 KB |
33.txt | TLE | 2107 ms | 67572 KB |
34.txt | TLE | 2108 ms | 67572 KB |
4.txt | TLE | 2107 ms | 67572 KB |
5.txt | AC | 23 ms | 3444 KB |
6.txt | AC | 21 ms | 3192 KB |
7.txt | TLE | 2107 ms | 68980 KB |
8.txt | TLE | 2108 ms | 67572 KB |
9.txt | TLE | 2108 ms | 67572 KB |
sample1.txt | AC | 18 ms | 3192 KB |
sample2.txt | AC | 17 ms | 3192 KB |
sample3.txt | AC | 17 ms | 3192 KB |