結果

問題 No.1588 Connection
ユーザー ziitaziita
提出日時 2021-09-08 12:30:12
言語 Rust
(1.77.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 1,458 bytes
コンパイル時間 919 ms
コンパイル使用メモリ 146,572 KB
実行使用メモリ 24,408 KB
平均クエリ数 563.31
最終ジャッジ日時 2023-08-26 17:58:22
合計ジャッジ時間 4,262 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
24,036 KB
testcase_01 AC 21 ms
24,408 KB
testcase_02 AC 20 ms
24,048 KB
testcase_03 AC 20 ms
24,372 KB
testcase_04 AC 20 ms
23,676 KB
testcase_05 AC 19 ms
23,568 KB
testcase_06 AC 22 ms
23,424 KB
testcase_07 AC 20 ms
23,460 KB
testcase_08 AC 22 ms
23,820 KB
testcase_09 AC 24 ms
23,976 KB
testcase_10 AC 23 ms
23,424 KB
testcase_11 AC 25 ms
23,712 KB
testcase_12 AC 49 ms
23,460 KB
testcase_13 AC 54 ms
23,424 KB
testcase_14 AC 20 ms
24,036 KB
testcase_15 AC 20 ms
23,592 KB
testcase_16 AC 20 ms
23,676 KB
testcase_17 AC 21 ms
23,712 KB
testcase_18 AC 20 ms
23,580 KB
testcase_19 AC 21 ms
24,396 KB
testcase_20 AC 22 ms
24,036 KB
testcase_21 AC 93 ms
24,276 KB
testcase_22 AC 87 ms
23,712 KB
testcase_23 AC 51 ms
23,424 KB
testcase_24 AC 37 ms
23,700 KB
testcase_25 AC 57 ms
24,168 KB
testcase_26 AC 56 ms
24,300 KB
testcase_27 AC 37 ms
23,460 KB
testcase_28 AC 30 ms
23,244 KB
testcase_29 AC 92 ms
24,180 KB
testcase_30 AC 98 ms
24,324 KB
testcase_31 AC 21 ms
24,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

fn read() -> Vec<String> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|s| String::from(s)).collect()
}

use std::cmp::*;
use std::collections::*;
use std::ops::*;
use std::marker::*;
 
const INF: i64 = std::i64::MAX/100;
const MOD: i64 = 1_000_000_007;
// const MOD: i64 = 998_244_353;

fn main() {
    let (n, m): (usize, usize) = {
        let a = read();
        (a[0].parse().unwrap(), a[1].parse().unwrap())
    };
    let mut seen = vec![vec![false;n];n];
    let mut ans = false;
    dfs(0,0,4,&mut seen,&mut ans);
    if ans {
        println!("Yes");
    }
    else {
        println!("No");
    }
}

fn dfs(x: usize, y: usize, d: usize, mut seen: &mut Vec<Vec<bool>>, mut ans: &mut bool){
    let n = seen.len();
    if x==n-1 && y==n-1 {
        *ans = true;
        return;
    }
    println!("{} {}",x+1,y+1);
    let t = read();
    if t[0]=="White" {
        return;
    }
    seen[x][y] = true;
    let dir = [(0,1),(1,0),(0,!0),(!0,0)];
    for (nd,&(tx,ty)) in dir.iter().enumerate() {
        if d<4 && d!=nd && nd%2==d%2 {
            continue;
        }
        let nx = x + tx;
        let ny = y + ty;
        if nx>=n || ny>=n {
            continue;
        }
        if seen[nx][ny] {
            continue;
        }
        seen[nx][ny] = true;
        dfs(nx,ny,nd,&mut seen,&mut ans);
    }
}


0