結果
問題 | No.1016 三目並べ |
ユーザー |
|
提出日時 | 2021-12-27 19:11:29 |
言語 | Rust (1.83.0 + proconio) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,828 bytes |
コンパイル時間 | 13,419 ms |
コンパイル使用メモリ | 382,860 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-10-01 05:56:04 |
合計ジャッジ時間 | 12,916 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 1 |
other | RE * 10 |
ソースコード
use std::io::{Write, BufWriter};// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8macro_rules! input {($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}macro_rules! input_inner {($next:expr) => {};($next:expr,) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}macro_rules! read_value {($next:expr, ( $($t:tt),* )) => { ($(read_value!($next, $t)),*) };($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));}fn main() {let out = std::io::stdout();let mut out = BufWriter::new(out.lock());macro_rules! puts {($($format:tt)*) => (let _ = write!(out,$($format)*););}input! {t: usize,ns: [(usize, chars); t],}for (n, s) in ns {let mut t = vec![0; n];for i in 0..n {t[i] = match s[i] {'o' => 1,'x' => 2,_ => 0,};}let mut res = 0;for i in 0..std::cmp::max(2, n) - 2 {let mut f = [0; 3];for j in 0..3 {f[t[i + j]] += 1;}if f == [1, 2, 0] || f == [0, 3, 0] {res = 1;}}for i in 0..std::cmp::max(3, n) - 3 {let mut f = [0; 3];for j in 0..4 {f[t[i + j]] += 1;}if f == [3, 1, 0] && t[i] == 0 && t[i + 3] == 0 {res = 1;}}for i in 0..std::cmp::max(4, n) - 4 {let mut f = [0; 3];for j in 0..5 {f[t[i + j]] += 1;}if f == [3, 2, 0] && t[i] == 1 && t[i + 4] == 1 {res = 1;}}let mut v = vec![];for i in 0..n {if t[i] == 0 { continue; }if t[i] == 2 {v.clear();continue;}v.push(i);while v.len() > 2 {v.remove(0);}if (v[1] - v[0]) % 2 == 0 {res = 1;}}puts!("{}\n", ["X", "O"][res]);}}