Submission #2789430
Source Code Expand
N, K = gets.split.map(&:to_i)
K2 = 2 * K
m = Array.new(K2 + 1){Array.new(K2 + 1, 0)}
readlines.map(&:split).each do |x, y, c|
x = x.to_i % K2
y = (y.to_i + (c == 'W' ? K : 0)) % K2
m[x + 1][y + 1] += 1
m[(x + K) % K2 + 1][(y + K) % K2 + 1] += 1
end
(1 .. K2).each do |i|
(1 .. K2).each do |j|
m[i][j] += m[i - 1][j] + m[i][j - 1] - m[i - 1][j - 1]
end
end
ans = 0
(1 .. K).each do |i|
(1 .. K).each do |j|
c = m[i + K][j + K] - m[i][j + K] - m[i + K][j] + m[i][j]
ans = c if c > ans
c = N - c
ans = c if c > ans
end
end
puts ans
Submission Info
| Submission Time | |
|---|---|
| Task | D - Checker |
| User | noriakiokubo |
| Language | Ruby (2.3.3) |
| Score | 500 |
| Code Size | 587 Byte |
| Status | AC |
| Exec Time | 1666 ms |
| Memory | 59924 KiB |
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 | 7 ms | 1788 KiB |
| 0_001.txt | AC | 1439 ms | 33148 KiB |
| 0_002.txt | AC | 7 ms | 1788 KiB |
| 1_003.txt | AC | 1378 ms | 33148 KiB |
| 1_004.txt | AC | 7 ms | 1788 KiB |
| 1_005.txt | AC | 7 ms | 1788 KiB |
| 1_006.txt | AC | 7 ms | 1788 KiB |
| 1_007.txt | AC | 21 ms | 2044 KiB |
| 1_008.txt | AC | 1418 ms | 33148 KiB |
| 1_009.txt | AC | 9 ms | 1916 KiB |
| 1_010.txt | AC | 9 ms | 1916 KiB |
| 1_011.txt | AC | 9 ms | 1916 KiB |
| 1_012.txt | AC | 23 ms | 2172 KiB |
| 1_013.txt | AC | 1414 ms | 33404 KiB |
| 1_014.txt | AC | 208 ms | 26364 KiB |
| 1_015.txt | AC | 210 ms | 26364 KiB |
| 1_016.txt | AC | 209 ms | 26364 KiB |
| 1_017.txt | AC | 227 ms | 26748 KiB |
| 1_018.txt | AC | 1666 ms | 59924 KiB |
| 1_019.txt | AC | 41 ms | 4604 KiB |
| 1_020.txt | AC | 41 ms | 4604 KiB |
| 1_021.txt | AC | 41 ms | 4604 KiB |
| 1_022.txt | AC | 41 ms | 4604 KiB |
| 1_023.txt | AC | 41 ms | 4604 KiB |
| 1_024.txt | AC | 41 ms | 4604 KiB |
| 1_025.txt | AC | 201 ms | 26364 KiB |
| 1_026.txt | AC | 1621 ms | 57980 KiB |
| 1_027.txt | AC | 201 ms | 26364 KiB |
| 1_028.txt | AC | 1630 ms | 57980 KiB |
| 1_029.txt | AC | 200 ms | 26364 KiB |
| 1_030.txt | AC | 1661 ms | 57980 KiB |