QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#79822 | #5519. Count Hamiltonian Cycles | yyyyxh | WA | 19ms | 1580kb | C++14 | 650b | 2023-02-20 22:29:04 | 2023-02-20 22:31:30 |
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 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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 1500kb
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: 19ms
memory: 1580kb
input:
1 1000000 BWBWBBBWWWBWBBBWBBWWWBWBBWWBWBWWWBBBBWBBWWBWBBBWBBBWWBWWBBBBWWWWBWBBWWBBWWWWBBBBWWBWWWWBBBWWBWBWWWBWWBWWBWWBWWBWWWWBWBWWWWWWBWWBWWBWBWBWBWWWBWBBBWBBBWWWBBBWBBBWBBWBWWBBBWWBWBWWWBBBBWBBBWWWBWBBBWBBWWBWBWWBBBWWWWBBWBBBWBBBBBBWBWBWBBBWBBBBBWBBBWWBWBWWBBWWWWBBBBBBBBBWBWWBBBWBWWBBBWBBBBWWBWWBWW...
output:
3254448
result:
ok 1 number(s): "3254448"
Test #3:
score: -100
Wrong Answer
time: 14ms
memory: 1496kb
input:
1 1000000 BWBBWBBWWBBBBWWBWWWBWWBWWBBWWWBBBBBWBBBBBWBWBBBBWBBWBWBBWWWWBWWWBBBWWWBBBWWWBBBWWWBWBBBBWWBWBWBBWBWBBBWWWWBWWBWWBWWWBWBWWWWBWWBBWWBWWBBWBBBWBWBBWWBBBWWWWBBWBWBBBWWWWBWWWWWBWBWWBWWBWWBWWWWBBBBWBBWWBBBBBBBBWBBBWBBBWWBWBWWBBWBWWBWWWWBWWBBBWBWWWWWWWWBWBWWBBBWWBWWWBWWWWBWWBBBBWBBBWBBBBWWBBBBBBB...
output:
177643374
result:
wrong answer 1st numbers differ - expected: '427204463', found: '177643374'