結果
| 問題 | No.1292 パタパタ三角形 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2022-11-17 00:12:51 | 
| 言語 | Rust (1.83.0 + proconio) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 26 ms / 2,000 ms | 
| コード長 | 1,063 bytes | 
| コンパイル時間 | 12,728 ms | 
| コンパイル使用メモリ | 393,552 KB | 
| 実行使用メモリ | 9,568 KB | 
| 最終ジャッジ日時 | 2024-09-17 18:43:52 | 
| 合計ジャッジ時間 | 14,311 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 14 | 
コンパイルメッセージ
warning: unused variable: `i` --> src/main.rs:16:54 | 16 | let idx = lines.iter().enumerate().filter(|&(i, &target)| target == c).nth(0).unwrap().0; | ^ help: if this is intentional, prefix it with an underscore: `_i` | = note: `#[warn(unused_variables)]` on by default
ソースコード
use std::collections::HashSet;
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let s = s.trim().chars().collect::<Vec<_>>();
    let mut pos = HashSet::new();
    let mut up = false;
    let mut x = 0isize;
    let mut y = 0isize;
    pos.insert((x, y));
    let mut lines = vec!['a', 'b', 'c'];
    for &c in s.iter() {
        let idx = lines.iter().enumerate().filter(|&(i, &target)| target == c).nth(0).unwrap().0;
        if up {
            match idx {
                0 => { y -= 1; lines.swap(1, 2); },
                1 => { x -= 1; lines.swap(0, 2); },
                2 => { x += 1; lines.swap(0, 1); },
                _ => { unreachable!(); }
            }
        } else {
            match idx {
                0 => { y += 1; lines.swap(1, 2); },
                1 => { x += 1; lines.swap(0, 2); },
                2 => { x -= 1; lines.swap(0, 1); },
                _ => { unreachable!(); }
            }
        }
        pos.insert((x, y));
        up = !up;
    }
    println!("{}", pos.len());
}
            
            
            
        