QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#244369#2271. High-Tech DetectiveNYCU_gAwr_gurA#WA 1ms3564kbC++201.7kb2023-11-08 23:54:542023-11-08 23:54:54

Judging History

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

  • [2023-11-08 23:54:54]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3564kb
  • [2023-11-08 23:54:54]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define matsuri pair<int,int>
const int iris = 1e9+7;
//const int iris = 998244353;
using namespace std;

int dp[10001][5001];
char owo[10001];
int arr[10001], cnt[10001], sf[10001], pr[10001], prI[10001], prO[10001];

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    for(int i=1;i<=n*2;i++)
    {
    	cin>>owo[i]>>arr[i];
    	cnt[arr[i]]++;
    	if(arr[i]==0)
    	{
    		if(owo[i]=='I')
    			pr[i]=1;
    		else
    			sf[i]=1;
		}
		pr[i]+=pr[i-1];
	}
	for(int i=1;i<=n*2;i++)
	{
		if(owo[i]=='I' && !(arr[i] && cnt[arr[i]]==2))
			prI[i]=1;
		if(owo[i]=='O' && !(arr[i] && cnt[arr[i]]==2))
			prO[i]=1;
		prO[i]+=prO[i-1];
		prI[i]+=prI[i-1];
	}
	for(int i=n*2-1;i>=0;i--)
		sf[i]+=sf[i+1];
	dp[0][0]=1;
    for(int i=1;i<=n*2;i++)
    {
    	if((arr[i] && cnt[arr[i]]==2) || (owo[i]=='I' && arr[i]!=0))
    	{
    		for(int j=0;j<=n;j++)
    			dp[i][j]=dp[i-1][j];
		}
		else if(owo[i]=='I')
		{
    		for(int j=1;j<=n;j++)
    			dp[i][j]=dp[i-1][j-1];
		}
		else if(arr[i])
		{
			for(int j=0;j<n;j++)
				dp[i][j]=dp[i-1][j+1];
			//cout<<'-'<<i<<' '<<'\n';
		}
		else
		{
			for(int j=0;j<=n;j++)
			{
				// prI[i]-prO[i-1]=x+j
				int sp=prI[i]-prO[i-1]-j;
				//cout<<i<<' '<<sp<<' '<<prI[i]<<' '<<prO[i-1]<<' '<<j<<'\n';
				if(j)
				{
					dp[i][j-1]+=dp[i-1][j]*j*sf[i];
					dp[i][j-1]%=iris;
				}
				dp[i][j]+=dp[i-1][j]*sp;
				dp[i][j]%=iris;
			}
		}
	}
	for(int i=1;i<=n*2;i++)
	{
		for(int j=0;j<=n;j++)
		{
			//cout<<dp[i][j]<<' ';
		}
		//cout<<'\n';
	}
	cout<<dp[n*2][0]<<'\n';

    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3460kb

input:

4
I 1
I 0
O 0
I 0
O 2
I 4
O 0
O 4

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3464kb

input:

3
I 0
I 0
I 0
O 0
O 0
O 0

output:

36

result:

ok single line: '36'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3564kb

input:

1
I 0
O 1

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3460kb

input:

2
I 0
I 1
O 1
O 0

output:

1

result:

ok single line: '1'

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3472kb

input:

4
I 0
I 0
O 0
O 0
I 0
I 3
O 0
O 0

output:

72

result:

wrong answer 1st lines differ - expected: '24', found: '72'