P1003 Rust 全RE求助
  • 板块题目总版
  • 楼主putee
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/5/5 15:03
  • 上次更新2024/5/5 16:34:03
查看原帖
P1003 Rust 全RE求助
1260426
putee楼主2024/5/5 15:03
use std::io::{self, Read};

fn main() {
    let mut buf = String::new();

    io::stdin().read_to_string(&mut buf).unwrap();

    let buf: Vec<&str> = buf.trim().split('\n').collect();

    let a: Vec<i64> = buf
        .last()
        .unwrap()
        .split(' ')
        .map(|x| x.parse().unwrap())
        .collect();

    let (a, b): (i64, i64) = (a[0], a[1]);

    for i in (1..buf.len() - 1).rev() {
        let x: Vec<i64> = buf[i].split(' ').map(|x| x.parse().unwrap()).collect();
        if x[0] <= a && a <= x[0] + x[2] && x[1] <= b && b <= x[1] + x[3] {
            println!("{}", i);
            break;
        }
        if i == 1 {
            println!("-1");
        }
    }

    return;
}

本地能跑。 picture

2024/5/5 15:03
加载中...