Submission #4037320
Source Code Expand
from itertools import accumulate from operator import add N, K = map(int, input().split()) K2 = 2 * K # Gss[i][j]: 「市松模様の黒い部分の右上のマス」が(i,j)のとき、満たせる要望の個数 Gss = [[0] * K2 for i in range(K2)] for i in range(N): x, y, c = input().split() x, y = int(x), int(y) # 要望を「0<=x<2K, 0<=y<K, 'B'」に変換する if c == 'W': x -= K x, y = x % K2, y % K2 if y >= K: x, y = (x - K) % K2, y - K # 要望を満たす「市松模様の黒い部分の右上のマス」に対して、+1する # (後で累積和を取る) Gss[x][y] += 1 Gss[x][y - K] += -1 if x != K: Gss[x - K][y - K] += 1 Gss[x - K][y] += -1 if x > K: Gss[0][y] += 1 Gss[0][y - K] += -1 # 累積和を取る Gss = [accumulate(Gs) for Gs in Gss] Gss = [accumulate(Gs) for Gs in zip(*Gss)] Gss = list(map(list, zip(*Gss))) # 転置 # 「K<=y<2K」の部分を、「0<=y<K」に重ね合わせる Gss = [map(add, Gss[i][:K], Gss[i - K][K:]) for i in range(K2)] # Gssの最大値が答え print(max(map(max, Gss)))
Submission Info
Submission Time | |
---|---|
Task | D - Checker |
User | juppy |
Language | Python (3.4.3) |
Score | 500 |
Code Size | 1190 Byte |
Status | AC |
Exec Time | 1526 ms |
Memory | 220532 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt |
All | 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt, 1_026.txt, 1_027.txt, 1_028.txt, 1_029.txt, 1_030.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 20 ms | 3188 KB |
0_001.txt | AC | 887 ms | 70644 KB |
0_002.txt | AC | 19 ms | 3064 KB |
1_003.txt | AC | 887 ms | 70644 KB |
1_004.txt | AC | 19 ms | 3064 KB |
1_005.txt | AC | 19 ms | 3064 KB |
1_006.txt | AC | 19 ms | 3064 KB |
1_007.txt | AC | 24 ms | 3828 KB |
1_008.txt | AC | 884 ms | 70644 KB |
1_009.txt | AC | 23 ms | 3064 KB |
1_010.txt | AC | 23 ms | 3064 KB |
1_011.txt | AC | 22 ms | 3064 KB |
1_012.txt | AC | 29 ms | 4468 KB |
1_013.txt | AC | 946 ms | 132596 KB |
1_014.txt | AC | 399 ms | 3064 KB |
1_015.txt | AC | 411 ms | 3064 KB |
1_016.txt | AC | 431 ms | 3064 KB |
1_017.txt | AC | 472 ms | 5492 KB |
1_018.txt | AC | 1526 ms | 220532 KB |
1_019.txt | AC | 62 ms | 5492 KB |
1_020.txt | AC | 63 ms | 5492 KB |
1_021.txt | AC | 68 ms | 5492 KB |
1_022.txt | AC | 68 ms | 5492 KB |
1_023.txt | AC | 65 ms | 4980 KB |
1_024.txt | AC | 65 ms | 4980 KB |
1_025.txt | AC | 431 ms | 3064 KB |
1_026.txt | AC | 1374 ms | 134260 KB |
1_027.txt | AC | 390 ms | 3064 KB |
1_028.txt | AC | 1390 ms | 197148 KB |
1_029.txt | AC | 396 ms | 3064 KB |
1_030.txt | AC | 1392 ms | 151200 KB |