Submission #2003977
Source Code Expand
import java.util.Scanner;
public class Main {
private int n;
private int k;
private int[] x;
private int[] y;
private String[] c;
public static void main(String[] args) {
new Main().run();
}
private void run() {
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
k = sc.nextInt();
x = new int[n];
y = new int[n];
c = new String[n];
for (int i = 0; i < n; i++) {
x[i] = sc.nextInt();
y[i] = sc.nextInt();
c[i] = sc.next();
}
int max = 0;
// 今回の0,0の内容と色を決める
for (int i = 0; i < k; i++) {
for (int j = 0; j < k; j++) {
for (int h = 0; h < 2; h++) {
// trueがW で falseがB
boolean colorFlag = h % 2 == 0;
// (0,0)のWでスタート
int count = calculate(i, j, colorFlag, n - max);
if (max < count) {
max = count;
}
if (n <= max) {
break;
}
}
}
}
System.out.println(max);
}
/**
*
* @param baseX
* @param baseY
* @param colorFlag
* @param failedLimit 失敗していい回数
* @return count 希望にそえた数
*/
public int calculate(int baseX, int baseY, boolean colorFlag, int failedLimit) {
// System.out.println("baseX:" + baseX + " baseY:" + baseY + " colorFlag:" + colorFlag);
int count = 0;
int failedCount = 0;
for (int i = 0; i < n; i++) {
int absoluteX = baseX + x[i];
int absoluteY = baseY + y[i];
int t = absoluteX / k + absoluteY / k;
boolean cf = colorFlag;
if (t % 2 == 1) {
// baseX,baseYと違う色
cf = !colorFlag;
}
String color = cf ? "W" : "B";
// System.out.println("t:" + t + " x[i]: " + x[i] + " y[i]:" + y[i] + " absoluteX:" + absoluteX + " absoluteY:" + absoluteY + " c[i]:" + c[i] + " color:" + color);
if (color.equals(c[i])) {
count++;
} else {
failedCount++;
// これ以上やってもmaxの更新はありえない
if (failedLimit <= failedCount) {
return -1;
}
}
}
return count;
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Checker |
| User | ee07030 |
| Language | Java8 (OpenJDK 1.8.0) |
| Score | 0 |
| Code Size | 2650 Byte |
| Status | TLE |
| Exec Time | 2207 ms |
| Memory | 99056 KiB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 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 | 97 ms | 20564 KiB |
| 0_001.txt | AC | 126 ms | 21204 KiB |
| 0_002.txt | AC | 98 ms | 23380 KiB |
| 1_003.txt | AC | 127 ms | 20052 KiB |
| 1_004.txt | AC | 96 ms | 21844 KiB |
| 1_005.txt | AC | 94 ms | 19796 KiB |
| 1_006.txt | AC | 98 ms | 21332 KiB |
| 1_007.txt | AC | 112 ms | 19668 KiB |
| 1_008.txt | AC | 130 ms | 21972 KiB |
| 1_009.txt | AC | 148 ms | 24788 KiB |
| 1_010.txt | AC | 155 ms | 25172 KiB |
| 1_011.txt | AC | 163 ms | 25708 KiB |
| 1_012.txt | AC | 645 ms | 26904 KiB |
| 1_013.txt | TLE | 2105 ms | 25916 KiB |
| 1_014.txt | AC | 705 ms | 97796 KiB |
| 1_015.txt | AC | 736 ms | 93328 KiB |
| 1_016.txt | AC | 846 ms | 98428 KiB |
| 1_017.txt | TLE | 2207 ms | 97452 KiB |
| 1_018.txt | TLE | 2109 ms | 96632 KiB |
| 1_019.txt | AC | 271 ms | 40844 KiB |
| 1_020.txt | AC | 259 ms | 40308 KiB |
| 1_021.txt | AC | 311 ms | 37864 KiB |
| 1_022.txt | AC | 311 ms | 38712 KiB |
| 1_023.txt | TLE | 2109 ms | 41968 KiB |
| 1_024.txt | TLE | 2105 ms | 41056 KiB |
| 1_025.txt | AC | 1116 ms | 98976 KiB |
| 1_026.txt | TLE | 2105 ms | 99056 KiB |
| 1_027.txt | AC | 1150 ms | 96192 KiB |
| 1_028.txt | TLE | 2109 ms | 95476 KiB |
| 1_029.txt | AC | 1147 ms | 95348 KiB |
| 1_030.txt | TLE | 2109 ms | 95700 KiB |