結果
| 問題 |
No.1109 調の判定
|
| コンテスト | |
| ユーザー |
fukafukatani
|
| 提出日時 | 2020-10-10 10:11:19 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 816 bytes |
| コンパイル時間 | 12,678 ms |
| コンパイル使用メモリ | 378,444 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-20 15:41:34 |
| 合計ジャッジ時間 | 14,493 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 43 |
コンパイルメッセージ
warning: unused variable: `n` --> src/main.rs:4:9 | 4 | let n = read::<usize>(); | ^ help: if this is intentional, prefix it with an underscore: `_n` | = note: `#[warn(unused_variables)]` on by default
ソースコード
use std::collections::*;
fn main() {
let n = read::<usize>();
let t = read_vec::<usize>();
let mut cands = vec![];
for i in 0..12 {
let d = vec![i, i + 2, i + 4, i + 5, i + 7, i + 9, i + 11]
.into_iter()
.map(|x| x % 12)
.collect::<HashSet<_>>();
if t.iter().all(|&x| d.contains(&x)) {
cands.push(i);
}
}
if cands.len() != 1 {
println!("-1");
return;
}
println!("{}", cands[0]);
}
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()
}
fukafukatani