結果
| 問題 | No.1292 パタパタ三角形 | 
| コンテスト | |
| ユーザー |  fukafukatani | 
| 提出日時 | 2020-11-20 21:42:45 | 
| 言語 | Rust (1.83.0 + proconio) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 26 ms / 2,000 ms | 
| コード長 | 1,907 bytes | 
| コンパイル時間 | 12,352 ms | 
| コンパイル使用メモリ | 385,472 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-23 12:49:21 | 
| 合計ジャッジ時間 | 13,478 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 14 | 
コンパイルメッセージ
warning: function `read_vec` is never used
  --> src/main.rs:75:4
   |
75 | fn read_vec<T: std::str::FromStr>() -> Vec<T> {
   |    ^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default
            
            ソースコード
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
use std::ops::Bound::*;
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}
fn main() {
    let s = read::<String>()
        .chars()
        .map(|ch| ch.to_digit(36).unwrap() as usize - 10)
        .collect::<Vec<_>>();
    let mut state = (2, 0); // 0: a, 1: b, 2: c
    let mut cur = (0, 0);
    let mut entried = vec![(0, 0)];
    for ch in s {
        if ch == state.0 {
            if state.1 == 0 {
                cur.1 -= 1;
            } else {
                cur.1 += 1;
            }
        } else if state.0 == 2 {
            if ch == 1 {
                cur.0 += 1;
                state.0 = 0;
            } else {
                cur.0 -= 1;
                state.0 = 1;
            }
        } else if state.0 == 1 {
            if ch == 0 {
                cur.0 += 1;
                state.0 = 2;
            } else {
                cur.0 -= 1;
                state.0 = 0;
            }
        } else if state.0 == 0 {
            if ch == 2 {
                cur.0 += 1;
                state.0 = 1;
            } else {
                cur.0 -= 1;
                state.0 = 2;
            }
        }
        state.1 = 1 - state.1;
        entried.push(cur);
    }
    entried.sort();
    entried.dedup();
    // debug!(entried);
    println!("{}", entried.len());
}
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
            
            
            
        