Submission #895832
Source Code Expand
import java.util.LinkedList; import java.util.List; import java.util.Scanner; import java.util.TreeMap; import java.util.TreeSet; public class Main { int w, h; TreeSet<C> set; TreeMap<Integer, List<C>> mapX, mapY; TreeMap<Pair, C> map; class C implements Comparable<C> { Pair p; long value; C(int x, int y, int value) { this.p = new Pair(x, y); this.value = value; } @Override public int compareTo(C o) { return this.p.compareTo(o.p); } } class Pair implements Comparable<Pair> { int x, y; Pair(int x, int y) { this.x = x; this.y = y; } @Override public int compareTo(Pair o) { if (this.x != o.x) { return this.x - o.x; } return this.y - o.y; } } void run() { Scanner sc = new Scanner(System.in); w = sc.nextInt(); h = sc.nextInt(); int n = sc.nextInt(); C[] c = new C[n]; set = new TreeSet<C>(); mapX = new TreeMap<Integer, List<C>>(); mapY = new TreeMap<Integer, List<C>>(); map = new TreeMap<Pair, C>(); for (int i = 0; i < n; i++) { int x = sc.nextInt(); int y = sc.nextInt(); int v = sc.nextInt(); C tmp = new C(x, y, v); c[i] = tmp; set.add(tmp); if (mapX.containsKey(x)) { mapX.get(x).add(tmp); } else { List<C> xlist = new LinkedList<C>(); xlist.add(tmp); mapX.put(x, xlist); } if (mapY.containsKey(y)) { mapY.get(y).add(tmp); } else { List<C> ylist = new LinkedList<C>(); ylist.add(tmp); mapY.put(y, ylist); } map.put(new Pair(x, y), new C(x, y, v)); } for (int i = 0; i < n; i++) { int x = c[i].p.x; int y = c[i].p.y; List<C> listX = mapX.get(x); List<C> listY = mapY.get(y); if (listX == null || listY == null) { continue; } for (C tmpX : listX) { for (C tmpY : listY) { int nx = tmpY.p.x; int ny = tmpX.p.y; // System.out.println(x + " " + y + " " + nx + " " + ny); long k = tmpX.value + tmpY.value - c[i].value; C tmpC = map.get(new Pair(nx, ny)); if ((tmpC != null && tmpC.value != k) || (k < 0)) { System.out.println("No"); return; } } } } System.out.println("Yes"); } public static void main(String[] args) { new Main().run(); } }
Submission Info
Submission Time | |
---|---|
Task | D - Grid and Integers |
User | fujisu |
Language | Java7 (OpenJDK 1.7.0) |
Score | 0 |
Code Size | 2315 Byte |
Status | WA |
Exec Time | 2108 ms |
Memory | 119664 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 800 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt, 1_46.txt, 1_47.txt, 1_48.txt, 1_49.txt, 1_50.txt, 1_51.txt, 1_52.txt, 1_53.txt, 1_54.txt, 1_55.txt, 1_56.txt, 1_57.txt, 1_58.txt, 1_59.txt, 1_60.txt, 1_61.txt, 1_62.txt, 1_63.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 131 ms | 9044 KB |
0_01.txt | AC | 129 ms | 9044 KB |
0_02.txt | AC | 129 ms | 9044 KB |
0_03.txt | AC | 128 ms | 9044 KB |
0_04.txt | AC | 129 ms | 9044 KB |
1_00.txt | AC | 127 ms | 9044 KB |
1_01.txt | AC | 128 ms | 9044 KB |
1_02.txt | AC | 128 ms | 9172 KB |
1_03.txt | AC | 130 ms | 9044 KB |
1_04.txt | AC | 129 ms | 9044 KB |
1_05.txt | AC | 133 ms | 9044 KB |
1_06.txt | AC | 1295 ms | 119664 KB |
1_07.txt | AC | 1317 ms | 118432 KB |
1_08.txt | AC | 1322 ms | 116636 KB |
1_09.txt | AC | 1156 ms | 116608 KB |
1_10.txt | AC | 1366 ms | 113908 KB |
1_11.txt | AC | 1182 ms | 113712 KB |
1_12.txt | AC | 1354 ms | 113876 KB |
1_13.txt | WA | 1388 ms | 114184 KB |
1_14.txt | AC | 1367 ms | 113828 KB |
1_15.txt | WA | 1358 ms | 114220 KB |
1_16.txt | AC | 1350 ms | 115064 KB |
1_17.txt | AC | 1082 ms | 114124 KB |
1_18.txt | AC | 1092 ms | 113684 KB |
1_19.txt | AC | 1090 ms | 113792 KB |
1_20.txt | WA | 1111 ms | 101108 KB |
1_21.txt | AC | 699 ms | 58096 KB |
1_22.txt | AC | 437 ms | 24520 KB |
1_23.txt | AC | 1015 ms | 103792 KB |
1_24.txt | WA | 1258 ms | 101740 KB |
1_25.txt | WA | 1061 ms | 101012 KB |
1_26.txt | AC | 490 ms | 31576 KB |
1_27.txt | AC | 532 ms | 31576 KB |
1_28.txt | WA | 1430 ms | 113684 KB |
1_29.txt | AC | 744 ms | 57784 KB |
1_30.txt | WA | 1341 ms | 113464 KB |
1_31.txt | AC | 775 ms | 65128 KB |
1_32.txt | WA | 1670 ms | 107344 KB |
1_33.txt | WA | 1331 ms | 114020 KB |
1_34.txt | AC | 533 ms | 36224 KB |
1_35.txt | TLE | 2108 ms | 109052 KB |
1_36.txt | AC | 571 ms | 36068 KB |
1_37.txt | WA | 855 ms | 62768 KB |
1_38.txt | AC | 1105 ms | 103472 KB |
1_39.txt | AC | 640 ms | 45384 KB |
1_40.txt | AC | 1071 ms | 103424 KB |
1_41.txt | AC | 736 ms | 58732 KB |
1_42.txt | AC | 1033 ms | 101852 KB |
1_43.txt | AC | 902 ms | 103004 KB |
1_44.txt | WA | 1656 ms | 102252 KB |
1_45.txt | WA | 798 ms | 56756 KB |
1_46.txt | WA | 1292 ms | 114168 KB |
1_47.txt | AC | 842 ms | 61292 KB |
1_48.txt | WA | 714 ms | 58192 KB |
1_49.txt | AC | 509 ms | 31728 KB |
1_50.txt | WA | 928 ms | 73216 KB |
1_51.txt | WA | 1427 ms | 111724 KB |
1_52.txt | AC | 476 ms | 30292 KB |
1_53.txt | AC | 548 ms | 36412 KB |
1_54.txt | AC | 710 ms | 57760 KB |
1_55.txt | AC | 1554 ms | 63448 KB |
1_56.txt | WA | 1083 ms | 102636 KB |
1_57.txt | WA | 1508 ms | 111512 KB |
1_58.txt | WA | 1216 ms | 103108 KB |
1_59.txt | AC | 431 ms | 26028 KB |
1_60.txt | AC | 130 ms | 9044 KB |
1_61.txt | AC | 129 ms | 9172 KB |
1_62.txt | AC | 130 ms | 9044 KB |
1_63.txt | AC | 129 ms | 9044 KB |