結果
| 問題 |
No.2692 How Many Times Reached?
|
| コンテスト | |
| ユーザー |
naut3
|
| 提出日時 | 2024-03-22 21:35:47 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,717 bytes |
| コンパイル時間 | 12,838 ms |
| コンパイル使用メモリ | 385,688 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-09-30 11:02:45 |
| 合計ジャッジ時間 | 15,780 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 39 WA * 4 |
ソースコード
#![allow(non_snake_case, unused_imports, unused_must_use)]
use std::io::{self, prelude::*};
use std::str;
fn main() {
let (stdin, stdout) = (io::stdin(), io::stdout());
let mut scan = Scanner::new(stdin.lock());
let mut out = io::BufWriter::new(stdout.lock());
macro_rules! input {
($T: ty) => {
scan.token::<$T>()
};
($T: ty, $N: expr) => {
(0..$N).map(|_| scan.token::<$T>()).collect::<Vec<_>>()
};
}
let N = input!(usize);
let S = (0..N)
.map(|_| input!(String).chars().collect::<Vec<_>>())
.collect::<Vec<_>>();
let mut ans = 0usize;
let is_bingo = |B: Vec<Vec<char>>| {
let mut cnt = 0;
for y in 0..N {
let mut isok = true;
for x in 0..N {
if B[y][x] != 'A' {
isok = false;
}
}
if isok {
cnt += 1;
}
}
for y in 0..N {
let mut isok = true;
for x in 0..N {
if B[x][y] != 'A' {
isok = false;
}
}
if isok {
cnt += 1;
}
}
let mut isok = true;
for i in 0..N {
if B[i][i] != 'A' {
isok = false;
}
}
if isok {
cnt += 1;
}
for i in 0..N {
if B[i][N - i - 1] != 'A' {
isok = false;
}
}
if isok {
cnt += 1;
}
return cnt;
};
for i in 0..N {
for j in 0..N {
if S[i][j] == '.' {
let mut T = S.clone();
T[i][j] = 'A';
ans += is_bingo(T);
}
}
}
writeln!(out, "{}", ans);
}
struct Scanner<R> {
reader: R,
buf_str: Vec<u8>,
buf_iter: str::SplitWhitespace<'static>,
}
impl<R: BufRead> Scanner<R> {
fn new(reader: R) -> Self {
Self {
reader,
buf_str: vec![],
buf_iter: "".split_whitespace(),
}
}
fn token<T: str::FromStr>(&mut self) -> T {
loop {
if let Some(token) = self.buf_iter.next() {
return token.parse().ok().expect("Failed parse");
}
self.buf_str.clear();
self.reader
.read_until(b'\n', &mut self.buf_str)
.expect("Failed read");
self.buf_iter = unsafe {
let slice = str::from_utf8_unchecked(&self.buf_str);
std::mem::transmute(slice.split_whitespace())
}
}
}
}
naut3