結果
| 問題 | No.3679 なんかでっかい虫リターンズ |
| コンテスト | |
| ユーザー |
msksknkn
|
| 提出日時 | 2026-09-12 20:13:18 |
| 言語 | Java (openjdk 26.0.2.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 56 ms / 2,000 ms |
| + 26µs | |
| コード長 | 1,495 bytes |
| 記録 | |
| コンパイル時間 | 3,036 ms |
| コンパイル使用メモリ | 86,176 KB |
| 実行使用メモリ | 42,712 KB |
| 最終ジャッジ日時 | 2026-09-12 20:13:24 |
| 合計ジャッジ時間 | 4,222 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
package no3679_nannkadekkaimushi;
import java.util.*;
public class Main {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
Scanner sc = new Scanner(System.in);
sc.nextInt();
sc.nextInt();
int x = sc.nextInt();
int y = sc.nextInt();
int hf = sc.nextInt();
int wf = sc.nextInt();
int he = sc.nextInt();
int we = sc.nextInt();
int p = sc.nextInt();
int q = sc.nextInt();
int ans = Math.abs(p - x) + Math.abs(q - y);
int l = 0;
//初期位置が虫の上
if(x <= hf) {
//System.out.println("Up");
//左側
if(y <= wf) {
l = Math.abs(y - wf) + Math.abs(x - hf);
x = hf;
y = wf;
}//右側
else if(y > we) {
l = Math.abs(y - we) + Math.abs(x - hf);
x = hf;
y = we;
}//真上
else {
l = Math.abs(x - hf);
x = hf;
}
}//初期位置が虫と同じくらいの高さ
else if(x > hf && x <= he) {
//左側
if(y <= wf) {
l = Math.abs(wf - y);
y = wf;
}//右側
else if(y > we) {
l = Math.abs(we - y);
y = we;
}//それ以外は動かない
}//初期位置が虫の下
else if(x > he) {
//左
if(y <= wf) {
l = Math.abs(x - he) + Math.abs(y - wf);
x = he;
y = wf;
}//右
else if(y > we) {
l = Math.abs(x - he) + Math.abs(y - we);
x = he;
y = we;
}//真下
else {
l = Math.abs(x - he);
x = he;
}
}ans += l + Math.abs(p - x) + Math.abs(q - y);
System.out.println(ans);
}
}
msksknkn