Submission #1173841
Source Code Expand
import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Random; import java.util.Scanner; public class Main { public static int[] dx = {1,0,-1,0}; public static int[] dy = {0,1,0,-1}; static Scanner sc = new Scanner(System.in); //static int[] arr; static ArrayList<String> list = new ArrayList<>(); static int[] capa ; static int[] cur; static int[][] map; static HashSet<Integer> set ; static int n,m,k; static HashMap<Integer, Integer> car = new HashMap<Integer,Integer>(); static HashMap<Integer, Integer> destination = new HashMap<Integer,Integer>(); public static void main(String[] args){ //String line = sc.nextLine(); int H =sc.nextInt(); int W = sc.nextInt(); int K = sc.nextInt(); int T= sc.nextInt(); //sc.nextLine(); map = new int[H+1][W+1]; for(int i=0; i<K; i++){ int x = sc.nextInt(); int y = sc.nextInt(); int fx = sc.nextInt(); int fy = sc.nextInt(); //sc.nextLine(); car.put(i, x*1000+y); destination.put(i, fx*1000+fy); //map[x][y] = 1; } boolean o = true; for(int i=0; i<T ; i++){ map = new int[H+1][W+1]; for(Map.Entry<Integer, Integer> e:car.entrySet()){ int x = e.getValue()/1000; int y = e.getValue()%1000; map[x][y]=1; } StringBuilder sb = new StringBuilder(); o = false; for(Map.Entry<Integer, Integer> e : car.entrySet()){ int num = e.getKey(); int cur = e.getValue(); int x = e.getValue()/1000; int y = e.getValue()%1000; int fx = destination.get(num)/1000; int fy = destination.get(num)%1000; int dis = Math.abs(fx-x)+Math.abs(fy-y); if(x==fx&& y == fy){ sb.append("-"); continue; } for(int j=0; j<4; j++){ int nx = x+dx[j]; int ny = y + dy[j]; int def = Math.abs(fx-nx)+Math.abs(fy-ny); if(nx>=1 && nx<=H && ny>=1 && ny<=W && map[nx][ny]==0 && def<dis){ cur = nx*1000+ny; car.put(num, cur); //map[x][y]=0; map[nx][ny]=1; sb.append(next(j)); o = true; break; } if(j==3)sb.append("-"); } } if(!o)break; list.add(sb.toString()); } System.out.println(list.size()); for(String s: list)System.out.println(s); } public static String next(int i) { if(i==0)return "D"; if(i==1)return "R"; if(i==2)return "U"; if(i==3)return "L"; return "-"; } }
Submission Info
Submission Time | |
---|---|
Task | B - 日本橋大渋滞 |
User | nectar |
Language | Java8 (OpenJDK 1.8.0) |
Score | 4617 |
Code Size | 3181 Byte |
Status | AC |
Exec Time | 203 ms |
Memory | 28272 KB |
Judge Result
Set Name | test_01 | test_02 | test_03 | test_04 | test_05 | test_06 | test_07 | test_08 | test_09 | test_10 | test_11 | test_12 | test_13 | test_14 | test_15 | test_16 | test_17 | test_18 | test_19 | test_20 | test_21 | test_22 | test_23 | test_24 | test_25 | test_26 | test_27 | test_28 | test_29 | test_30 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 156 / 50000 | 159 / 50000 | 158 / 50000 | 156 / 50000 | 176 / 50000 | 160 / 50000 | 155 / 50000 | 158 / 50000 | 147 / 50000 | 149 / 50000 | 161 / 50000 | 155 / 50000 | 150 / 50000 | 161 / 50000 | 146 / 50000 | 157 / 50000 | 154 / 50000 | 150 / 50000 | 154 / 50000 | 155 / 50000 | 161 / 50000 | 153 / 50000 | 151 / 50000 | 143 / 50000 | 149 / 50000 | 154 / 50000 | 152 / 50000 | 137 / 50000 | 149 / 50000 | 151 / 50000 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Status |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Set Name | Test Cases |
---|---|
test_01 | subtask_01_01.txt |
test_02 | subtask_01_02.txt |
test_03 | subtask_01_03.txt |
test_04 | subtask_01_04.txt |
test_05 | subtask_01_05.txt |
test_06 | subtask_01_06.txt |
test_07 | subtask_01_07.txt |
test_08 | subtask_01_08.txt |
test_09 | subtask_01_09.txt |
test_10 | subtask_01_10.txt |
test_11 | subtask_01_11.txt |
test_12 | subtask_01_12.txt |
test_13 | subtask_01_13.txt |
test_14 | subtask_01_14.txt |
test_15 | subtask_01_15.txt |
test_16 | subtask_01_16.txt |
test_17 | subtask_01_17.txt |
test_18 | subtask_01_18.txt |
test_19 | subtask_01_19.txt |
test_20 | subtask_01_20.txt |
test_21 | subtask_01_21.txt |
test_22 | subtask_01_22.txt |
test_23 | subtask_01_23.txt |
test_24 | subtask_01_24.txt |
test_25 | subtask_01_25.txt |
test_26 | subtask_01_26.txt |
test_27 | subtask_01_27.txt |
test_28 | subtask_01_28.txt |
test_29 | subtask_01_29.txt |
test_30 | subtask_01_30.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
subtask_01_01.txt | AC | 184 ms | 26128 KB |
subtask_01_02.txt | AC | 178 ms | 27744 KB |
subtask_01_03.txt | AC | 203 ms | 23452 KB |
subtask_01_04.txt | AC | 189 ms | 22244 KB |
subtask_01_05.txt | AC | 180 ms | 26916 KB |
subtask_01_06.txt | AC | 193 ms | 26388 KB |
subtask_01_07.txt | AC | 185 ms | 27060 KB |
subtask_01_08.txt | AC | 177 ms | 25956 KB |
subtask_01_09.txt | AC | 182 ms | 23604 KB |
subtask_01_10.txt | AC | 181 ms | 26564 KB |
subtask_01_11.txt | AC | 187 ms | 26412 KB |
subtask_01_12.txt | AC | 170 ms | 26184 KB |
subtask_01_13.txt | AC | 197 ms | 27792 KB |
subtask_01_14.txt | AC | 183 ms | 26160 KB |
subtask_01_15.txt | AC | 192 ms | 26700 KB |
subtask_01_16.txt | AC | 188 ms | 24320 KB |
subtask_01_17.txt | AC | 179 ms | 24704 KB |
subtask_01_18.txt | AC | 186 ms | 24036 KB |
subtask_01_19.txt | AC | 193 ms | 27480 KB |
subtask_01_20.txt | AC | 197 ms | 24876 KB |
subtask_01_21.txt | AC | 189 ms | 23336 KB |
subtask_01_22.txt | AC | 190 ms | 25820 KB |
subtask_01_23.txt | AC | 179 ms | 27936 KB |
subtask_01_24.txt | AC | 180 ms | 23088 KB |
subtask_01_25.txt | AC | 177 ms | 26564 KB |
subtask_01_26.txt | AC | 182 ms | 25560 KB |
subtask_01_27.txt | AC | 195 ms | 28272 KB |
subtask_01_28.txt | AC | 192 ms | 24292 KB |
subtask_01_29.txt | AC | 184 ms | 25280 KB |
subtask_01_30.txt | AC | 193 ms | 27444 KB |