QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#166882 | #5519. Count Hamiltonian Cycles | 275307894a | WA | 18ms | 7660kb | C++14 | 958b | 2023-09-06 20:01:34 | 2023-09-06 20:01:34 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=2e6+5,M=N*20+5,K=600+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const ll INF=1e18+7;mt19937 rnd(time(0));
int n,Sum[N];char s[N];
void Solve(){
int i,j;scanf("%d",&n);
scanf("%s",s+1);
int S1=0,S2=0;ll ans=1;
for(i=1;i<=2*n;i++){
S1+=(s[i]=='W'?1:-1);
if(!S1) ans=ans*2%mod;
else ans=ans*abs(S1)%mod;
}
printf("%lld\n",ans*(mod+1)/4%mod);
}
int main(){
int t;
scanf("%d",&t);
// t=1;
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3956kb
input:
3 2 WWBB 3 WBWBWB 7 WWWWBWBBWWBBBB
output:
1 2 62208
result:
ok 3 number(s): "1 2 62208"
Test #2:
score: 0
Accepted
time: 17ms
memory: 6460kb
input:
1 1000000 BWBWBBBWWWBWBBBWBBWWWBWBBWWBWBWWWBBBBWBBWWBWBBBWBBBWWBWWBBBBWWWWBWBBWWBBWWWWBBBBWWBWWWWBBBWWBWBWWWBWWBWWBWWBWWBWWWWBWBWWWWWWBWWBWWBWBWBWBWWWBWBBBWBBBWWWBBBWBBBWBBWBWWBBBWWBWBWWWBBBBWBBBWWWBWBBBWBBWWBWBWWBBBWWWWBBWBBBWBBBBBBWBWBWBBBWBBBBBWBBBWWBWBWWBBWWWWBBBBBBBBBWBWWBBBWBWWBBBWBBBBWWBWWBWW...
output:
3254448
result:
ok 1 number(s): "3254448"
Test #3:
score: -100
Wrong Answer
time: 18ms
memory: 7660kb
input:
1 1000000 BWBBWBBWWBBBBWWBWWWBWWBWWBBWWWBBBBBWBBBBBWBWBBBBWBBWBWBBWWWWBWWWBBBWWWBBBWWWBBBWWWBWBBBBWWBWBWBBWBWBBBWWWWBWWBWWBWWWBWBWWWWBWWBBWWBWWBBWBBBWBWBBWWBBBWWWWBBWBWBBBWWWWBWWWWWBWBWWBWWBWWBWWWWBBBBWBBWWBBBBBBBBWBBBWBBBWWBWBWWBBWBWWBWWWWBWWBBBWBWWWWWWWWBWBWWBBBWWBWWWBWWWWBWWBBBBWBBBWBBBBWWBBBBBBB...
output:
926326639
result:
wrong answer 1st numbers differ - expected: '427204463', found: '926326639'