結果

問題 No.3140 Weird Parentheses Game
ユーザー atcoder8
提出日時 2025-05-16 22:07:23
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 538 bytes
コンパイル時間 11,030 ms
コンパイル使用メモリ 397,812 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-05-16 22:07:37
合計ジャッジ時間 12,058 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;

fn main() {
    input! {
        _n: usize,
        s: String,
    }

    let mut grundy = 0_usize;
    let mut level = 0_usize;
    let mut max_level = 0_usize;
    for c in s.chars() {
        if c == '(' {
            level += 1;
            max_level = max_level.max(level);
        } else {
            level -= 1;

            if level == 0 {
                grundy ^= max_level;
                max_level = 0;
            }
        }
    }

    println!("{}", if grundy != 0 { "First" } else { "Second" });
}
0