Submission #2544827


Source Code Expand

struct Place {
    t: i32,
    x: i32,
    y: i32
}

impl Place {
    fn from_vec(vec: Vec<&str>) -> Place{
        Place {
            t: vec[0].parse::<i32>().unwrap(),
            x: vec[1].parse::<i32>().unwrap(),
            y: vec[2].parse::<i32>().unwrap()
        }
    }
}

fn c_can_move(place:&Place, goal:&Place) -> bool {
    let dt = place.t - goal.t; 
    let dx = place.x - goal.x; 
    let dy = place.y - goal.y;
    if ( ( dt.abs() - dx.abs() - dy.abs() ) % 2 == 0 )  && ( dt.abs() > dx.abs() + dy.abs() ) {
        true
    } else {
        false
    }
}

fn c() {
    let mut can_traveling = true;
    let mut line = String::new();
    let _ = std::io::stdin().read_line(&mut line);
    let n = line.trim().parse::<i32>().unwrap();
    let mut place = Place{ t: 0, x: 0, y: 0 };
    for _ in 0..n {
        line = String::new();
        let _ = std::io::stdin().read_line(&mut line);
        let vec: Vec<&str> = line.split_whitespace().collect();
        let goal = Place::from_vec(vec);
        if c_can_move(&place, &goal) {
            place = goal;
        } else {
            can_traveling = false;
            break;
        }
    }
    if can_traveling {
        print!("Yes");
    } else {
        print!("No");
    }
}

fn main() {
    c();
}

Submission Info

Submission Time
Task C - Traveling
User wonderfulboyx
Language Rust (1.15.1)
Score 0
Code Size 1328 Byte
Status WA
Exec Time 2 ms
Memory 4352 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 2
WA × 1
AC × 7
WA × 6
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt
Case Name Status Exec Time Memory
0_000.txt WA 2 ms 4352 KB
0_001.txt AC 2 ms 4352 KB
0_002.txt AC 2 ms 4352 KB
1_003.txt WA 2 ms 4352 KB
1_004.txt WA 2 ms 4352 KB
1_005.txt AC 2 ms 4352 KB
1_006.txt WA 2 ms 4352 KB
1_007.txt WA 2 ms 4352 KB
1_008.txt WA 2 ms 4352 KB
1_009.txt AC 2 ms 4352 KB
1_010.txt AC 2 ms 4352 KB
1_011.txt AC 2 ms 4352 KB
1_012.txt AC 2 ms 4352 KB