Submission #2482856
Source Code Expand
package main import ( "bufio" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) func nextInt() int { sc.Scan() i, e := strconv.Atoi(sc.Text()) if e != nil { panic(e) } return i } func nextString() string { sc.Scan() return sc.Text() } func main() { var n int var k int fmt.Scan(&n, &k) k2 := k*2 // 0 ≦ x,y ≦ 2K に圧縮 squares := make([][]int, k2) for i := range squares { squares[i] = make([]int, k2) } sc.Split(bufio.ScanWords) for i := 0; i < n; i++ { x := nextInt() y := nextInt() color := nextString() // 'W'はY方向にKずらした'B'と同値 if color == "W" { y += k } squares[x % k2][y % k2]++ } // 計算量削減のために累積和を事前算出 for i := 0; i < k2; i++ { for j := 1; j < k2; j++ { squares[i][j] += squares[i][j-1] } } for j := 0; j < k2; j++ { for i := 1; i < k2; i++ { squares[i][j] += squares[i-1][j] } } max_ := 0 end := k2-1 for i := 0; i < k; i++ { for j := 0; j < k; j++ { // ex) k = 2 // ■ □ □ ■ // j+k □ ■ ■ □ // □ ■ ■ □ // j ■ □ □ ■ // i i+k cnt := (squares[i][j]) + (squares[end][j] - squares[i+k][j]) + (squares[i+k][j+k] - squares[i+k][j] - squares[i][j+k] + squares[i][j]) + (squares[i][end] - squares[i][j+k]) + (squares[end][end] - squares[end][j+k] - squares[i+k][end] + squares[i+k][j+k]) max_ = max(max(cnt, n - cnt), max_) } } fmt.Print(max_) } func max(a int, b int) int { if a > b { return a } else { return b } }
Submission Info
Submission Time | |
---|---|
Task | D - Checker |
User | fink |
Language | Go (1.6) |
Score | 500 |
Code Size | 1797 Byte |
Status | AC |
Exec Time | 186 ms |
Memory | 37120 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 | 1 ms | 640 KB |
0_001.txt | AC | 115 ms | 33920 KB |
0_002.txt | AC | 1 ms | 640 KB |
1_003.txt | AC | 114 ms | 33920 KB |
1_004.txt | AC | 1 ms | 640 KB |
1_005.txt | AC | 1 ms | 640 KB |
1_006.txt | AC | 1 ms | 640 KB |
1_007.txt | AC | 2 ms | 1024 KB |
1_008.txt | AC | 114 ms | 33920 KB |
1_009.txt | AC | 2 ms | 640 KB |
1_010.txt | AC | 2 ms | 640 KB |
1_011.txt | AC | 2 ms | 640 KB |
1_012.txt | AC | 2 ms | 1024 KB |
1_013.txt | AC | 116 ms | 33920 KB |
1_014.txt | AC | 62 ms | 3840 KB |
1_015.txt | AC | 62 ms | 3840 KB |
1_016.txt | AC | 62 ms | 3840 KB |
1_017.txt | AC | 64 ms | 4224 KB |
1_018.txt | AC | 186 ms | 37120 KB |
1_019.txt | AC | 6 ms | 1024 KB |
1_020.txt | AC | 6 ms | 1024 KB |
1_021.txt | AC | 6 ms | 1024 KB |
1_022.txt | AC | 6 ms | 1024 KB |
1_023.txt | AC | 7 ms | 1024 KB |
1_024.txt | AC | 6 ms | 1024 KB |
1_025.txt | AC | 46 ms | 1920 KB |
1_026.txt | AC | 164 ms | 35456 KB |
1_027.txt | AC | 48 ms | 2304 KB |
1_028.txt | AC | 159 ms | 35584 KB |
1_029.txt | AC | 48 ms | 2304 KB |
1_030.txt | AC | 165 ms | 35584 KB |