QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#197225#4436. Link with Bracket Sequence IIyiyiyi#WA 262ms11136kbC++141.1kb2023-10-02 13:25:502023-10-02 13:25:51

Judging History

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

  • [2023-10-02 13:25:51]
  • 评测
  • 测评结果:WA
  • 用时:262ms
  • 内存:11136kb
  • [2023-10-02 13:25:50]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define sqr(x) ((x)*(x))
#define N 1000
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
const int mo=1000000007;
inline int read(){
	int x=0,w=0;char ch=getchar();
	while (!isdigit(ch))w|=ch=='-',ch=getchar();
	while (isdigit(ch))x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	return w?-x:x;
}
ll f[N][N][2];
int a[N];
void solve(){
	int n=read(),m=read();
//	memset(f,0,sizeof(f));
	for (int i=1;i<=n;++i)a[i]=read(),f[i+1][i][0]=f[i+1][i][1]=1;
	for (int len=2;len<=n;len+=2){
		for (int i=1;i+len-1<=n;++i){
			int j=i+len-1;//cout<<i<<" "<<j<<"!!"<<endl;
			for (int k=0;k<2;++k)
				if (a[i]==-a[j]){
					if (a[i])f[i][j][k]=f[i+1][j-1][1];
					else f[i][j][k]=1ll*f[i+1][j-1][1]*m%mo;
				}else{
					if (a[i]&&a[j])f[i][j][k]=0;
					else f[i][j][k]=f[i+1][j-1][1];
				}
			for (int k=i+1;k<j-1;k+=2)
				f[i][j][1]=(f[i][j][1]+1ll*f[i][k][0]*f[k+1][j][1])%mo;
		}
	}
	cout<<f[1][n][1]<<endl;
}
signed main(){
	int T=read();
	while (T--)solve();
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 262ms
memory: 11136kb

input:

20
10 1
1 -1 0 -1 -1 1 -1 1 0 0
10 2
0 1 1 -2 1 -2 -1 1 -2 1
8 5
0 0 4 0 0 2 -2 0
9 5
0 0 0 -3 0 0 0 0 0
8 5
0 1 0 0 0 0 0 0
498 249013689
239722195 0 0 0 -59682797 187213467 0 0 220688278 0 0 -133178217 165866643 -165866643 216987003 55229518 -55229518 -216987003 0 82546192 0 0 0 0 -62330427 -19687...

output:

16
0
160
0
1750
794099921
796396708
180786104
345214555
36228136
1
646409125
790867257
347678716
74014753
960399457
951689409
227852148
343052576
776801212

result:

wrong answer 1st lines differ - expected: '0', found: '16'