QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#79822#5519. Count Hamiltonian CyclesyyyyxhWA 19ms1580kbC++14650b2023-02-20 22:29:042023-02-20 22:31:30

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-20 22:31:30]
  • 评测
  • 测评结果:WA
  • 用时:19ms
  • 内存:1580kb
  • [2023-02-20 22:29:04]
  • 提交

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'