結果
| 問題 |
No.3040 Aoiスコア
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-28 23:46:14 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 124 ms / 1,000 ms |
| コード長 | 1,371 bytes |
| コンパイル時間 | 11,323 ms |
| コンパイル使用メモリ | 399,948 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-20 21:01:52 |
| 合計ジャッジ時間 | 12,773 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
use proconio::{
input,
marker::{Chars, Usize1},
};
fn main() {
input! {
n: usize,
m: usize,
s: Chars,
ab: [(Usize1, Usize1); m],
}
let mut pow_26 = [1usize; 6000];
for i in 1..6000 {
pow_26[i] = (pow_26[i - 1] * 26) % 998244353;
}
let mut graph = vec![vec![]; n];
for (a, b) in ab {
graph[a].push(b);
graph[b].push(a);
}
let question_count = s.iter().filter(|&&x| x == '?').count();
let mut ans = 0;
for center in 0..n {
let question_count = match s[center] {
'o' => question_count,
'?' => question_count - 1,
_ => continue,
};
for &head in &graph[center] {
let question_count = match s[head] {
'a' => question_count,
'?' => question_count - 1,
_ => continue,
};
for &tail in &graph[center] {
if head == tail {
continue;
}
let question_count = match s[tail] {
'i' => question_count,
'?' => question_count - 1,
_ => continue,
};
ans += pow_26[question_count];
ans %= 998244353;
}
}
}
println!("{}", ans);
}