結果
問題 | No.1909 Detect from Substrings |
ユーザー | phspls |
提出日時 | 2022-10-09 23:48:23 |
言語 | Rust (1.77.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,785 bytes |
コンパイル時間 | 2,355 ms |
コンパイル使用メモリ | 153,416 KB |
実行使用メモリ | 36,236 KB |
最終ジャッジ日時 | 2023-09-06 02:15:52 |
合計ジャッジ時間 | 7,000 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,384 KB |
testcase_03 | WA | - |
testcase_04 | AC | 2 ms
4,384 KB |
testcase_05 | AC | 5 ms
4,384 KB |
testcase_06 | AC | 9 ms
6,100 KB |
testcase_07 | AC | 9 ms
6,136 KB |
testcase_08 | AC | 96 ms
36,100 KB |
testcase_09 | AC | 95 ms
36,084 KB |
testcase_10 | AC | 44 ms
17,840 KB |
testcase_11 | AC | 46 ms
17,884 KB |
testcase_12 | AC | 26 ms
11,884 KB |
testcase_13 | AC | 96 ms
36,160 KB |
testcase_14 | AC | 96 ms
36,000 KB |
testcase_15 | AC | 97 ms
36,008 KB |
testcase_16 | AC | 27 ms
11,848 KB |
testcase_17 | AC | 10 ms
6,324 KB |
testcase_18 | AC | 9 ms
6,112 KB |
testcase_19 | AC | 9 ms
6,012 KB |
testcase_20 | AC | 9 ms
6,116 KB |
testcase_21 | AC | 97 ms
36,040 KB |
testcase_22 | AC | 98 ms
36,040 KB |
testcase_23 | AC | 45 ms
17,912 KB |
testcase_24 | AC | 45 ms
17,848 KB |
testcase_25 | AC | 27 ms
11,916 KB |
testcase_26 | AC | 98 ms
35,988 KB |
testcase_27 | AC | 99 ms
36,212 KB |
testcase_28 | AC | 97 ms
36,140 KB |
testcase_29 | AC | 98 ms
36,132 KB |
testcase_30 | AC | 97 ms
36,144 KB |
testcase_31 | AC | 100 ms
35,980 KB |
testcase_32 | AC | 98 ms
36,028 KB |
testcase_33 | AC | 98 ms
36,052 KB |
testcase_34 | AC | 96 ms
36,144 KB |
testcase_35 | AC | 97 ms
36,196 KB |
testcase_36 | AC | 99 ms
36,228 KB |
testcase_37 | AC | 100 ms
36,236 KB |
testcase_38 | AC | 96 ms
36,140 KB |
コンパイルメッセージ
warning: unused import: `std::fmt::format` --> Main.rs:1:5 | 1 | use std::fmt::format; | ^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: 1 warning emitted
ソースコード
use std::fmt::format; fn main() { let mut nm = String::new(); std::io::stdin().read_line(&mut nm).ok(); let nm: Vec<usize> = nm.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = nm[0]; let m = nm[1]; let words = (0..n).map(|_| { let mut temp = String::new(); std::io::stdin().read_line(&mut temp).ok(); let temp = temp.trim(); temp.chars().collect::<Vec<_>>() }) .collect::<Vec<_>>(); let a = &words[0]; let b = &words[1]; let start = (0..m).filter(|&i| a[i] != b[i]).nth(0).unwrap(); let end = (0..m).rev().filter(|&i| a[i] != b[i]).nth(0).unwrap(); let t1 = format!("{}{}{}{}" , (0..start).map(|i| a[i].to_string()).collect::<Vec<_>>().join("") , (start..=end).map(|i| a[i].to_string()).collect::<Vec<_>>().join("") , b[end] , (end+1..m).map(|i| a[i].to_string()).collect::<Vec<_>>().join("")) .chars().collect::<Vec<_>>(); let t2 = format!("{}{}{}{}" , (0..start).map(|i| a[i].to_string()).collect::<Vec<_>>().join("") , (start..=end).map(|i| b[i].to_string()).collect::<Vec<_>>().join("") , a[end] , (end+1..m).map(|i| a[i].to_string()).collect::<Vec<_>>().join("")) .chars().collect::<Vec<_>>(); let mut result = 0usize; let word_ok = |i: usize, t: &Vec<char>| { let start = (0..m+1).filter(|&j| j == m || words[i][j] != t[j]).nth(0).unwrap(); (start+1..m).map(|j| words[i][j] == t[j+1]).fold(true, |x, y| x && y) }; let temp = (0..n).filter(|&i| word_ok(i, &t1)).count() == n; if temp { result += 1; } let temp = (0..n).filter(|&i| word_ok(i, &t2)).count() == n; if temp { result += 1; } println!("{}", result); }