AtCoder Regular Contest 025

Submission #1365420

Source codeソースコード

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
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()

class Ruiwa():
    def __init__(self, a):
        self.H = h = len(a)
        self.W = w = len(a[0])
        self.R = r = a
        for i in range(h):
            for j in range(1,w):
                r[i][j] += r[i][j-1]

        for i in range(1,h):
            for j in range(w):
                r[i][j] += r[i-1][j]

    def search(self, x1, y1, x2, y2):
        if x1 > x2 or y1 > y2:
            return 0

        r = self.R
        rr = r[y2][x2]
        if x1 > 0 and y1 > 0:
            return rr - r[y1-1][x2] - r[y2][x1-1] + r[y1-1][x1-1]
        if x1 > 0:
            rr -= r[y2][x1-1]
        if y1 > 0:
            rr -= r[y1-1][x2]

        return rr

def main():
    h,w = LI()
    a = []
    for i in range(h):
        t = LI()
        a.append([t[j] if (i+j)%2 == 0 else -t[j] for j in range(w)])

    rui = Ruiwa(a)
    r = 0
    for i in range(h):
        for j in range(w):
            for ii in range(i,h):
                for jj in range(j,w):
                    if rui.search(j,i,jj,ii) == 0:
                        t = (ii-i+1) * (jj-j+1)
                        if r < t:
                            r = t

    return r


print(main())

Submission

Task問題 B - チョコレート
User nameユーザ名 iehn
Created time投稿日時
Language言語 Python3 (3.4.3)
Status状態 TLE
Score得点 0
Source lengthソースコード長 1746 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - subtask0_sample-01.txt,subtask0_sample-02.txt,subtask0_sample-03.txt,subtask0_sample-04.txt,subtask0_sample-05.txt
All 0 / 100 subtask0_sample-01.txt,subtask0_sample-02.txt,subtask0_sample-03.txt,subtask0_sample-04.txt,subtask0_sample-05.txt,subtask1_01.txt,subtask1_02.txt,subtask1_03.txt,subtask1_04.txt,subtask1_05.txt,subtask1_06.txt,subtask1_07.txt,subtask1_08.txt,subtask1_09.txt,subtask1_10.txt,subtask1_11.txt,subtask1_12.txt,subtask1_13.txt,subtask1_14.txt,subtask1_15.txt,subtask1_16.txt,subtask1_17.txt,subtask1_18.txt,subtask1_19.txt,subtask1_20.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
subtask0_sample-01.txt AC 90 ms 8132 KB
subtask0_sample-02.txt AC 41 ms 5448 KB
subtask0_sample-03.txt AC 41 ms 5448 KB
subtask0_sample-04.txt AC 41 ms 5448 KB
subtask0_sample-05.txt AC 41 ms 5452 KB
subtask1_01.txt AC 41 ms 5448 KB
subtask1_02.txt AC 41 ms 5448 KB
subtask1_03.txt AC 41 ms 5448 KB
subtask1_04.txt AC 42 ms 5452 KB
subtask1_05.txt AC 56 ms 5448 KB
subtask1_06.txt AC 102 ms 5448 KB
subtask1_07.txt AC 42 ms 5452 KB
subtask1_08.txt AC 49 ms 5448 KB
subtask1_09.txt TLE
subtask1_10.txt TLE
subtask1_11.txt TLE
subtask1_12.txt TLE
subtask1_13.txt TLE
subtask1_14.txt TLE
subtask1_15.txt TLE
subtask1_16.txt TLE
subtask1_17.txt TLE
subtask1_18.txt AC 41 ms 5452 KB
subtask1_19.txt AC 51 ms 5456 KB
subtask1_20.txt TLE