QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#79820 | #5519. Count Hamiltonian Cycles | yyyyxh | WA | 14ms | 1744kb | C++14 | 661b | 2023-02-20 22:27:21 | 2023-02-20 22:27:25 |
Judging History
answer
#include <cstdio>
using namespace std;
int read(){
char c=getchar();int x=0;
while(c<48||c>57) c=getchar();
do x=(x<<1)+(x<<3)+(c^48),c=getchar();
while(c>=48&&c<=57);
return x;
}
const int N=2000003,P=998244353;
int main(){
int tc=read();
while(tc--){
int n=read();
char cc=getchar();
while(cc!='W'&&cc!='B') cc=getchar();
int cur=0,res=1;
char fir;
for(int i=1;i<=n+n;++i){
if(cur>0) res=(long long)res*cur%P;
if(cur<0) res=(long long)res*-cur%P;
if(!cur) res=(res<<1)%P;
if(i==1) fir=cc;
if(fir==cc) ++cur;
else --cur;
cc=getchar();
}
res>>=2;
printf("%d\n",res);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 1484kb
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: 12ms
memory: 1744kb
input:
1 1000000 BWBWBBBWWWBWBBBWBBWWWBWBBWWBWBWWWBBBBWBBWWBWBBBWBBBWWBWWBBBBWWWWBWBBWWBBWWWWBBBBWWBWWWWBBBWWBWBWWWBWWBWWBWWBWWBWWWWBWBWWWWWWBWWBWWBWBWBWBWWWBWBBBWBBBWWWBBBWBBBWBBWBWWBBBWWBWBWWWBBBBWBBBWWWBWBBBWBBWWBWBWWBBBWWWWBBWBBBWBBBBBBWBWBWBBBWBBBBBWBBBWWBWBWWBBWWWWBBBBBBBBBWBWWBBBWBWWBBBWBBBBWWBWWBWW...
output:
3254448
result:
ok 1 number(s): "3254448"
Test #3:
score: -100
Wrong Answer
time: 14ms
memory: 1500kb
input:
1 1000000 BWBBWBBWWBBBBWWBWWWBWWBWWBBWWWBBBBBWBBBBBWBWBBBBWBBWBWBBWWWWBWWWBBBWWWBBBWWWBBBWWWBWBBBBWWBWBWBBWBWBBBWWWWBWWBWWBWWWBWBWWWWBWWBBWWBWWBBWBBBWBWBBWWBBBWWWWBBWBWBBBWWWWBWWWWWBWBWWBWWBWWBWWWWBBBBWBBWWBBBBBBBBWBBBWBBBWWBWBWWBBWBWWBWWWWBWWBBBWBWWWWWWWWBWBWWBBBWWBWWWBWWWWBWWBBBBWBBBWBBBBWWBBBBBBB...
output:
177643374
result:
wrong answer 1st numbers differ - expected: '427204463', found: '177643374'