結果
問題 | No.20 砂漠のオアシス |
ユーザー | core123 |
提出日時 | 2019-04-24 17:04:51 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,764 bytes |
コンパイル時間 | 2,021 ms |
コンパイル使用メモリ | 80,072 KB |
実行使用メモリ | 87,460 KB |
最終ジャッジ日時 | 2024-04-25 15:52:36 |
合計ジャッジ時間 | 14,361 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 125 ms
53,928 KB |
testcase_01 | AC | 133 ms
54,308 KB |
testcase_02 | AC | 130 ms
54,208 KB |
testcase_03 | AC | 203 ms
58,224 KB |
testcase_04 | AC | 243 ms
58,704 KB |
testcase_05 | AC | 325 ms
59,156 KB |
testcase_06 | AC | 434 ms
59,572 KB |
testcase_07 | AC | 4,500 ms
87,460 KB |
testcase_08 | AC | 689 ms
68,744 KB |
testcase_09 | AC | 1,483 ms
69,572 KB |
testcase_10 | WA | - |
testcase_11 | AC | 108 ms
53,016 KB |
testcase_12 | AC | 229 ms
58,136 KB |
testcase_13 | AC | 241 ms
58,084 KB |
testcase_14 | AC | 328 ms
62,608 KB |
testcase_15 | AC | 282 ms
59,000 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 442 ms
66,480 KB |
testcase_20 | AC | 201 ms
57,672 KB |
ソースコード
import java.util.*; public class Main { public static final int[] dx= {-1,0,0,1}; public static final int[] dy= {0,-1,1,0}; public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int v=sc.nextInt(); int ox=sc.nextInt()-1; int oy=sc.nextInt()-1; int[][] l=new int[n][n]; for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { l[i][j]=sc.nextInt(); } } int[][] hp=new int[n][n]; for(int[] ints:hp) { Arrays.fill(ints, 0); } Deque<FixedIntTuple> deq=new ArrayDeque<>(); deq.add(new FixedIntTuple(0, 0,v,false)); while(deq.size()>0) { FixedIntTuple fit=deq.removeFirst(); //System.out.println(fit); if(hp[fit.x][fit.y]<fit.v) { hp[fit.x][fit.y]=fit.v; if(fit.x==n-1&&fit.y==n-1)break; }else { continue; } for(int i=0;i<4;i++) { int x=fit.x+dx[i]; int y=fit.y+dy[i]; if(x<0||x>=n||y<0||y>=n)continue; int vn=fit.v-l[x][y]; boolean f=fit.f; if(vn<=0)continue; if(!fit.f&&(fit.x==ox&&fit.y==oy)) { vn*=2; f=true; } deq.addLast(new FixedIntTuple(x, y, vn,f)); } } if(hp[n-1][n-1]>0) { System.out.println("YES"); }else { System.out.println("NO"); } } public static class FixedIntTuple{ public final int x,y,v; public final boolean f; /** * @param x * @param y */ public FixedIntTuple(int x, int y,int v,boolean f) { super(); this.x = x; this.y = y; this.v=v; this.f=f; } /* (非 Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { // TODO 自動生成されたメソッド・スタブ return String.format("FixedIntTuple:(%d,%d,%d)",x,y,v); } } }