QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#430403#5519. Count Hamiltonian Cyclesship2077RE 1ms3836kbC++14376b2024-06-03 19:47:432024-06-03 19:47:45

Judging History

你现在查看的是最新测评结果

  • [2024-06-03 19:47:45]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3836kb
  • [2024-06-03 19:47:43]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int mod=998244353;
char s[1000005];
void solve(){ int n,ans=1;
    scanf("%d%s",&n,s+1);
    for (int i=1,tmp=0;i<n<<1;i++){
        tmp+=s[i]=='B'?1:-1;
        ans=1ll*ans*(tmp?abs(tmp):2)%mod;
    }
    printf("%d\n",1ll*ans*(mod+1>>1)%mod);
}
int main(){int T;scanf("%d",&T);while (T--) solve();return 0;}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3836kb

input:

3
2
WWBB
3
WBWBWB
7
WWWWBWBBWWBBBB

output:

1
2
62208

result:

ok 3 number(s): "1 2 62208"

Test #2:

score: -100
Runtime Error

input:

1
1000000
BWBWBBBWWWBWBBBWBBWWWBWBBWWBWBWWWBBBBWBBWWBWBBBWBBBWWBWWBBBBWWWWBWBBWWBBWWWWBBBBWWBWWWWBBBWWBWBWWWBWWBWWBWWBWWBWWWWBWBWWWWWWBWWBWWBWBWBWBWWWBWBBBWBBBWWWBBBWBBBWBBWBWWBBBWWBWBWWWBBBBWBBBWWWBWBBBWBBWWBWBWWBBBWWWWBBWBBBWBBBBBBWBWBWBBBWBBBBBWBBBWWBWBWWBBWWWWBBBBBBBBBWBWWBBBWBWWBBBWBBBBWWBWWBWW...

output:


result: