Submission #896101
Source Code Expand
import java.util.LinkedList; import java.util.List; import java.util.Scanner; import java.util.TreeMap; public class Main { int w, h; TreeMap<Integer, List<C>> mapX, mapY; TreeMap<Pair, C> map; class C implements Comparable<C> { Pair p; long value; C(int x, int y, long 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]; 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; 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; 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 | 2163 Byte |
Status | WA |
Exec Time | 2108 ms |
Memory | 117676 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 | 9040 KB |
0_02.txt | AC | 129 ms | 9044 KB |
0_03.txt | AC | 130 ms | 9044 KB |
0_04.txt | AC | 130 ms | 9040 KB |
1_00.txt | AC | 128 ms | 9044 KB |
1_01.txt | AC | 129 ms | 9040 KB |
1_02.txt | AC | 130 ms | 9040 KB |
1_03.txt | AC | 129 ms | 9044 KB |
1_04.txt | AC | 130 ms | 9044 KB |
1_05.txt | AC | 130 ms | 9044 KB |
1_06.txt | AC | 1212 ms | 117676 KB |
1_07.txt | AC | 1259 ms | 116020 KB |
1_08.txt | AC | 1233 ms | 113448 KB |
1_09.txt | AC | 1069 ms | 113604 KB |
1_10.txt | AC | 1308 ms | 111220 KB |
1_11.txt | AC | 1127 ms | 110368 KB |
1_12.txt | AC | 1299 ms | 110720 KB |
1_13.txt | WA | 1309 ms | 111088 KB |
1_14.txt | AC | 1316 ms | 111024 KB |
1_15.txt | WA | 1316 ms | 110348 KB |
1_16.txt | AC | 1320 ms | 111832 KB |
1_17.txt | AC | 1014 ms | 110856 KB |
1_18.txt | AC | 1020 ms | 110604 KB |
1_19.txt | AC | 1029 ms | 110752 KB |
1_20.txt | WA | 1084 ms | 98872 KB |
1_21.txt | AC | 696 ms | 56976 KB |
1_22.txt | AC | 445 ms | 24392 KB |
1_23.txt | AC | 1010 ms | 100744 KB |
1_24.txt | WA | 1232 ms | 98984 KB |
1_25.txt | WA | 1030 ms | 98976 KB |
1_26.txt | AC | 485 ms | 31664 KB |
1_27.txt | AC | 521 ms | 32032 KB |
1_28.txt | WA | 1422 ms | 110280 KB |
1_29.txt | AC | 723 ms | 57212 KB |
1_30.txt | WA | 1298 ms | 110424 KB |
1_31.txt | AC | 767 ms | 63488 KB |
1_32.txt | WA | 1723 ms | 103620 KB |
1_33.txt | WA | 1292 ms | 111120 KB |
1_34.txt | AC | 541 ms | 36028 KB |
1_35.txt | TLE | 2108 ms | 105176 KB |
1_36.txt | AC | 556 ms | 35676 KB |
1_37.txt | WA | 837 ms | 62104 KB |
1_38.txt | AC | 1048 ms | 101344 KB |
1_39.txt | AC | 630 ms | 44772 KB |
1_40.txt | AC | 1044 ms | 101680 KB |
1_41.txt | AC | 719 ms | 57156 KB |
1_42.txt | AC | 995 ms | 98476 KB |
1_43.txt | AC | 812 ms | 89684 KB |
1_44.txt | WA | 1597 ms | 99708 KB |
1_45.txt | WA | 776 ms | 56240 KB |
1_46.txt | WA | 1263 ms | 110544 KB |
1_47.txt | AC | 827 ms | 59920 KB |
1_48.txt | WA | 710 ms | 57316 KB |
1_49.txt | AC | 493 ms | 31064 KB |
1_50.txt | WA | 911 ms | 70440 KB |
1_51.txt | WA | 1381 ms | 108196 KB |
1_52.txt | AC | 476 ms | 31760 KB |
1_53.txt | AC | 556 ms | 35740 KB |
1_54.txt | AC | 702 ms | 57176 KB |
1_55.txt | AC | 1548 ms | 61668 KB |
1_56.txt | WA | 1045 ms | 100608 KB |
1_57.txt | WA | 1433 ms | 108992 KB |
1_58.txt | WA | 1186 ms | 101092 KB |
1_59.txt | AC | 440 ms | 25548 KB |
1_60.txt | AC | 130 ms | 9044 KB |
1_61.txt | AC | 129 ms | 9044 KB |
1_62.txt | AC | 129 ms | 9040 KB |
1_63.txt | AC | 130 ms | 9044 KB |