結果
| 問題 | No.3439 [Cherry 8th Tune] どの頂点にいた頃に戻りたいのか? |
| コンテスト | |
| ユーザー |
👑 Kazun
|
| 提出日時 | 2024-05-06 17:19:00 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 700 bytes |
| 記録 | |
| コンパイル時間 | 379 ms |
| コンパイル使用メモリ | 82,884 KB |
| 実行使用メモリ | 67,440 KB |
| 最終ジャッジ日時 | 2026-01-23 20:50:41 |
| 合計ジャッジ時間 | 7,404 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 2 |
| other | RE * 37 |
ソースコード
def solve():
N = int(input())
S = f"*{input().strip()}"
Mod = 998244353
inv = [0] * (N + 2); inv[1] = 1
for x in range(2, N + 2):
q, r = divmod(Mod, x)
inv[x] = (- q * inv[r]) % Mod
total = 0
g = 0
for i in range(1, N + 1):
if i < N and S[i] == 'G':
g += 1
continue
a = (g + 1) * (g + 2) % Mod
total += a * inv[i + 1]; total %= Mod
g = 0
coef = (N + 1) * inv[2] % Mod
return coef * total % Mod
#==================================================
import sys
input = sys.stdin.readline
write = sys.stdout.write
T = int(input())
write("\n".join(map(str, [solve() for t in range(T)])))
Kazun