Contest Duration: - (local time) (90 minutes) Back to Home

Submission #19061

Source Code Expand

Copy
```import java.io.BufferedReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Queue;

public class Main {

public static class State implements Comparable<State> {
int nx;
int ny;
int t;

public State(int x, int y, int _t) {
nx = x;
ny = y;
t = _t;
}

@Override
public int compareTo(State arg0) {
return t - arg0.t;
}
}

static int[] dx = {1, 0, -1, 0};
static int[] dy = {0, 1, 0, -1};

public static void main(String[] args) throws IOException {
int N = Integer.valueOf(sz[0]);
int M = Integer.valueOf(sz[1]);

int[][] data = new int[N+2][M+2];
int sx = 0, sy = 0;
int gx = 0, gy = 0;
for (int i = 0 ; i < N ; i++) {
for (int j = 0 ; j < M ; j++) {
if (line.charAt(j) == 's') {
data[i+1][j+1] = 11;
sx = j+1;
sy = i+1;
} else if (line.charAt(j) == 'g') {
data[i+1][j+1] = 12;
gx = j+1;
gy = i+1;
} else if (line.charAt(j) == '#') {
} else {
data[i+1][j+1] = line.charAt(j) - '0';
}
}
}

double[][] dvalue = new double[10][5001];
for (int v = 1 ; v <= 9 ; v++) {
dvalue[v][0] = v;
for (int t = 0 ; t < 5000 ; t++) {
dvalue[v][t+1] = dvalue[v][t] * 99 / 100;
}
}

double max = 9.0d;
double min = 0.0d;
boolean reached = false;
for (int cur = 0 ; cur < 200 ; cur++) {
double med = (max + min) / 2.0d;
if (Math.abs(min - med) < 10e-11) {
break;
}
double[][] maxl = new double[N+2][M+2];
for (int d = 0 ; d < N+2 ; d++) {
Arrays.fill(maxl[d], 0.0d);
}
Queue<State> q = new PriorityQueue<State>();
boolean isok = false;
while (q.size() >= 1) {
State stat = q.poll();
for (int d = 0 ; d < 4 ; d++) {
int tx = (stat.nx + dx[d]);
int ty = (stat.ny + dy[d]);
int tt = stat.t + 1;
if (data[ty][tx] == 0) {
continue;
}
if (tt >= 5000) {
continue;
}

int lightval = data[ty][tx];
if (lightval == 11) {
continue;
}
if (lightval == 12) {
isok = true;
break;
}
if (dvalue[lightval][tt] < med) {
continue;
}
if (maxl[ty][tx] < dvalue[lightval][tt]) {
maxl[ty][tx] = dvalue[lightval][tt];
}
}
}
if (isok) {
reached = true;
min = med;
} else {
max = med;
}
}

if (reached) {
System.out.println(min);
} else {
System.out.println("-1");
}
}
}```

#### Submission Info

Submission Time 2012-05-27 20:54:04+0900 C - 暗闇帰り道 hamadu Java (OpenJDK 1.7.0) 0 2836 Byte WA 2398 ms 52408 KB

#### Judge Result

Set Name all
Score / Max Score 0 / 100
Status
 AC × 60 WA × 4
Set Name Test Cases
all 00_mini_01.txt, 00_mini_02.txt, 00_mini_03.txt, 00_mini_04.txt, 00_mini_05.txt, 00_sample_01.txt, 00_sample_02.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 01_rnd_10.txt, 01_rnd_11.txt, 01_rnd_12.txt, 01_rnd_13.txt, 01_rnd_14.txt, 01_rnd_15.txt, 01_rnd_16.txt, 01_rnd_17.txt, 01_rnd_18.txt, 01_rnd_19.txt, 01_rnd_20.txt, 02_maxrnd_01.txt, 02_maxrnd_02.txt, 02_maxrnd_03.txt, 02_maxrnd_04.txt, 02_maxrnd_05.txt, 02_maxrnd_06.txt, 02_maxrnd_07.txt, 02_maxrnd_08.txt, 02_maxrnd_09.txt, 02_maxrnd_10.txt, 02_maxrnd_11.txt, 02_maxrnd_12.txt, 02_maxrnd_13.txt, 02_maxrnd_14.txt, 02_maxrnd_15.txt, 02_maxrnd_16.txt, 02_maxrnd_17.txt, 02_maxrnd_18.txt, 02_maxrnd_19.txt, 03_hard_01.txt, 03_hard_02.txt, 03_hard_03.txt, 03_hard_04.txt, 03_hard_05.txt, 03_hard_06.txt, 03_hard_07.txt, 03_hard_08.txt, 04_open_01.txt, 04_open_02.txt, 05_minihard_01.txt, 05_minihard_02.txt, 05_minihard_03.txt, 05_minihard_04.txt, 05_minihard_05.txt, 05_minihard_06.txt, 05_minihard_07.txt, 05_minihard_08.txt
Case Name Status Exec Time Memory
00_mini_01.txt AC 423 ms 22492 KB
00_mini_02.txt AC 384 ms 22228 KB
00_mini_03.txt AC 397 ms 22392 KB
00_mini_04.txt AC 391 ms 22492 KB
00_mini_05.txt AC 370 ms 21572 KB
00_sample_01.txt AC 365 ms 22084 KB
00_sample_02.txt AC 406 ms 22272 KB
01_rnd_01.txt AC 2152 ms 47348 KB
01_rnd_02.txt AC 692 ms 34892 KB
01_rnd_03.txt AC 495 ms 34044 KB
01_rnd_04.txt AC 590 ms 35448 KB
01_rnd_05.txt AC 495 ms 30972 KB
01_rnd_06.txt AC 442 ms 27932 KB
01_rnd_07.txt AC 509 ms 33436 KB
01_rnd_08.txt AC 799 ms 36944 KB
01_rnd_09.txt AC 916 ms 37392 KB
01_rnd_10.txt AC 1040 ms 35060 KB
01_rnd_11.txt AC 747 ms 34936 KB
01_rnd_12.txt AC 656 ms 33148 KB
01_rnd_13.txt AC 587 ms 38344 KB
01_rnd_14.txt AC 1224 ms 35656 KB
01_rnd_15.txt AC 841 ms 34312 KB
01_rnd_16.txt AC 460 ms 35300 KB
01_rnd_17.txt AC 724 ms 33748 KB
01_rnd_18.txt AC 421 ms 29160 KB
01_rnd_19.txt AC 448 ms 32396 KB
01_rnd_20.txt AC 436 ms 28540 KB
02_maxrnd_01.txt AC 936 ms 42628 KB
02_maxrnd_02.txt AC 831 ms 40940 KB
02_maxrnd_03.txt AC 965 ms 44040 KB
02_maxrnd_04.txt AC 1445 ms 47468 KB
02_maxrnd_05.txt AC 970 ms 41496 KB
02_maxrnd_06.txt AC 2216 ms 51048 KB
02_maxrnd_07.txt AC 643 ms 38484 KB
02_maxrnd_08.txt AC 583 ms 37548 KB
02_maxrnd_09.txt AC 2232 ms 51108 KB
02_maxrnd_10.txt AC 739 ms 38008 KB
02_maxrnd_11.txt AC 2077 ms 50972 KB
02_maxrnd_12.txt AC 1188 ms 38564 KB
02_maxrnd_13.txt AC 1446 ms 47944 KB
02_maxrnd_14.txt AC 1587 ms 49920 KB
02_maxrnd_15.txt AC 683 ms 44064 KB
02_maxrnd_16.txt AC 1225 ms 46336 KB
02_maxrnd_17.txt AC 989 ms 43164 KB
02_maxrnd_18.txt AC 549 ms 38856 KB
02_maxrnd_19.txt AC 588 ms 37080 KB
03_hard_01.txt AC 2255 ms 51360 KB
03_hard_02.txt AC 2289 ms 52408 KB
03_hard_03.txt WA 509 ms 37028 KB
03_hard_04.txt WA 551 ms 39104 KB
03_hard_05.txt AC 2253 ms 51348 KB
03_hard_06.txt AC 2316 ms 51076 KB
03_hard_07.txt WA 531 ms 36320 KB
03_hard_08.txt WA 768 ms 36624 KB
04_open_01.txt AC 2398 ms 50816 KB
04_open_02.txt AC 2265 ms 51084 KB
05_minihard_01.txt AC 430 ms 26752 KB
05_minihard_02.txt AC 428 ms 26836 KB
05_minihard_03.txt AC 399 ms 25660 KB
05_minihard_04.txt AC 415 ms 25992 KB
05_minihard_05.txt AC 422 ms 26484 KB
05_minihard_06.txt AC 433 ms 26476 KB
05_minihard_07.txt AC 416 ms 26264 KB
05_minihard_08.txt AC 415 ms 26044 KB