結果
| 問題 |
No.2267 群の公理
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-04-14 21:44:59 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 1,009 bytes |
| コンパイル時間 | 13,110 ms |
| コンパイル使用メモリ | 377,708 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-10 12:27:25 |
| 合計ジャッジ時間 | 14,290 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 50 |
ソースコード
fn main() {
println!("{}", if solve() { "Yes" } else { "No" });
}
fn solve() -> bool {
let n = {
let mut line = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim().parse::<usize>().unwrap()
};
let mut mat = vec![];
for _ in 0..n {
let mut line = String::new();
std::io::stdin().read_line(&mut line).unwrap();
mat.push(
line.split_whitespace()
.map(|x| x.parse::<usize>().unwrap())
.collect::<Vec<_>>(),
);
}
for i in 0..n {
for j in 0..n {
for k in 0..n {
if mat[mat[i][j]][k] != mat[i][mat[j][k]] {
return false;
}
}
}
}
let e = (0..n).find(|&x| (0..n).all(|i| mat[i][x] == i && mat[x][i] == i));
let e = if let Some(e) = e {
e
} else {
return false;
};
(0..n).all(|i| (0..n).any(|x| mat[i][x] == e && mat[x][i] == e))
}