結果

問題 No.607 開通777年記念
ユーザー aimyaimy
提出日時 2017-12-07 10:55:16
言語 Rust
(1.77.0 + proconio)
結果
WA  
実行時間 -
コード長 3,112 bytes
コンパイル時間 14,065 ms
コンパイル使用メモリ 402,072 KB
実行使用メモリ 10,112 KB
最終ジャッジ日時 2024-05-06 19:14:46
合計ジャッジ時間 12,273 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,812 KB
testcase_02 AC 1 ms
6,816 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 WA -
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 8 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 40 ms
9,984 KB
testcase_12 AC 35 ms
10,112 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end`
  --> src/main.rs:51:9
   |
51 |     buf.trim_right().parse::<T>().ok().unwrap()
   |         ^^^^^^^^^^
   |
   = note: `#[warn(deprecated)]` on by default
help: replace the use of the deprecated method
   |
51 |     buf.trim_end().parse::<T>().ok().unwrap()
   |         ~~~~~~~~

warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end`
  --> src/main.rs:66:22
   |
66 |     let mut it = buf.trim_right().split_whitespace();
   |                      ^^^^^^^^^^
   |
help: replace the use of the deprecated method
   |
66 |     let mut it = buf.trim_end().split_whitespace();
   |                      ~~~~~~~~

warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end`
  --> src/main.rs:84:22
   |
84 |     let mut it = buf.trim_right().split_whitespace();
   |                      ^^^^^^^^^^
   |
help: replace the use of the deprecated method
   |
84 |     let mut it = buf.trim_end().split_whitespace();
   |                      ~~~~~~~~

warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end`
   --> src/main.rs:103:9
    |
103 |     buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
    |         ^^^^^^^^^^
    |
help: replace the use of the deprecated method
    |
103 |     buf.trim_end().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
    |         ~~~~~~~~

warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end`
   --> src/main.rs:118:9
    |
118 |     buf.trim_right().chars().collect()
    |         ^^^^^^^^^^
    |
help: replace the use of the deprecated method
    |
118 |     buf.trim_end().chars().collect()
    |         ~~~~~~~~

ソースコード

diff #

#[allow(unused_macros)]
macro_rules! debug {
  ($($e:expr), *) => {println!(concat!($(stringify!($e), " = {:?}\n"), *), $($e), *)}
}

fn main() {
  let (n, m) = get::tuple::<usize,usize>();
  let xss = get::lists::<isize>(m);
  
  let syakutori = |xs: &[isize], k| {
    use std::cmp::Ordering::*;
    let mut acc = xs[0];
    let mut i = 0;
    let mut j = 0;
    while i<n && j<n {
      match (acc.cmp(&k), i == j, j == n-1) {
        (Equal, _, _) => {return true},
        (Greater, true, false) => {i += 1; j += 1; acc = xs[i]},
        (Less, _, false) => {j += 1; acc += xs[j]},
        (_, _, true) => {return false},
        (Greater, _, _) => {acc -= xs[i]; i += 1},
      }
    }
    unreachable!()
  };
  
  let succeed = || {
    let mut ans = false;
    let mut acc = vec![0; n];
    for i in 0 .. m {
      for j in 0 .. n {acc[j] += xss[i][j]}
      if syakutori(&acc, 777) {ans = true; break}
    }
    // debug!(acc);
    ans 
  };
  
  let ans = if succeed() {"YES"} else {"NO"};
  println!("{}", ans)
}

#[allow(dead_code)]
mod get {
  use std::io::*;
  use std::str::*;

  pub fn val<T: FromStr>() -> T {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().parse::<T>().ok().unwrap()
  }

  pub fn vals<T: FromStr>(n: usize) -> Vec<T> {
    let mut vec: Vec<T> = vec![];
    for _ in 0 .. n {
      vec.push(val());
    }
    vec
  }

  pub fn tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    (x, y)
  }

  pub fn tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {
    let mut vec: Vec<(T1, T2)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple());
    }
    vec
  }

  pub fn tuple3<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    let z = it.next().unwrap().parse::<T3>().ok().unwrap();
    (x, y, z)
  }

  pub fn tuple3s<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {
    let mut vec: Vec<(T1, T2, T3)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple3());
    }
    vec
  }

  pub fn list<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
  }

  pub fn lists<T: FromStr>(h: usize) -> Vec<Vec<T>> {
    let mut mat: Vec<Vec<T>> = vec![];
    for _ in 0 .. h {
      mat.push(list());
    }
    mat
  }

  pub fn chars() -> Vec<char> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().chars().collect()
  }
}
0