Submission #173152


Source Code Expand

Copy
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
const ll mod = 1000000007;
int N;
int A[2020];
ll mod_pow(ll x,ll n){
	ll res = 1;
	while(n > 0){
		if(n & 1)res = (res * x)%mod;
		x = (x * x)%mod;
		n >>=1;
	}
	return res%mod;
}
ll C(int c,int r){

	ll X = 1,Y = 1;
	for(int i = 1;i <=r;i++){
		Y =(Y*i)%mod;
		X =(X*(i + c - r))%mod;
	}
	return X*mod_pow(Y, mod - 2);

}
int main(){
	cin>>N;
	for(int i = 0;i < N;i++){
		cin>>A[i];
	}

	ll ans = 1;
	for(int i = 0;i < N - 1;i++){
		if(A[i]==-1){
			int pre = i;
			int last;
			last = i;
			while(A[last]==-1){
				last++;
			}
			ans =(ans*C(A[last] - A[pre -1] + last - pre,last - pre))%mod;
			i = last;
		}
	}
	cout <<ans%mod<<endl;
	return 0;
}

Submission Info

Submission Time
Task C - タコヤ木
User togatoga
Language C++ (G++ 4.6.4)
Score 0
Code Size 1529 Byte
Status WA
Exec Time 25 ms
Memory 924 KB

Judge Result

Set Name Sample Subtask1 Subtask2 Subtask3
Score / Max Score 0 / 0 0 / 50 0 / 30 0 / 20
Status
AC × 3
AC × 11
WA × 3
AC × 19
WA × 7
AC × 23
WA × 13
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 sample_01.txt, sample_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt
Subtask2 sample_01.txt, sample_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt
Subtask3 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask3_01.txt, subtask3_02.txt, subtask3_03.txt, subtask3_04.txt, subtask3_05.txt, subtask3_06.txt, subtask3_07.txt, subtask3_08.txt, subtask3_09.txt, subtask3_10.txt, subtask3_11.txt, subtask3_12.txt
Case Name Status Exec Time Memory
sample_01.txt AC 21 ms 920 KB
sample_02.txt AC 21 ms 916 KB
sample_03.txt AC 22 ms 924 KB
subtask1_01.txt AC 23 ms 832 KB
subtask1_02.txt AC 23 ms 824 KB
subtask1_03.txt AC 25 ms 800 KB
subtask1_04.txt WA 21 ms 796 KB
subtask1_05.txt WA 22 ms 792 KB
subtask1_06.txt AC 25 ms 796 KB
subtask1_07.txt AC 24 ms 792 KB
subtask1_08.txt AC 22 ms 784 KB
subtask1_09.txt AC 24 ms 916 KB
subtask1_10.txt AC 22 ms 772 KB
subtask1_11.txt AC 22 ms 792 KB
subtask1_12.txt WA 22 ms 916 KB
subtask2_01.txt AC 23 ms 796 KB
subtask2_02.txt AC 22 ms 916 KB
subtask2_03.txt AC 22 ms 920 KB
subtask2_04.txt AC 22 ms 712 KB
subtask2_05.txt AC 22 ms 912 KB
subtask2_06.txt WA 22 ms 876 KB
subtask2_07.txt AC 24 ms 796 KB
subtask2_08.txt AC 22 ms 816 KB
subtask2_09.txt AC 22 ms 924 KB
subtask2_10.txt WA 22 ms 812 KB
subtask2_11.txt WA 22 ms 796 KB
subtask2_12.txt WA 22 ms 808 KB
subtask3_01.txt AC 22 ms 812 KB
subtask3_02.txt AC 22 ms 796 KB
subtask3_03.txt AC 22 ms 916 KB
subtask3_04.txt WA 22 ms 808 KB
subtask3_05.txt WA 20 ms 796 KB
subtask3_06.txt WA 22 ms 796 KB
subtask3_07.txt AC 22 ms 916 KB
subtask3_08.txt AC 22 ms 796 KB
subtask3_09.txt AC 23 ms 852 KB
subtask3_10.txt WA 22 ms 808 KB
subtask3_11.txt WA 22 ms 796 KB
subtask3_12.txt WA 24 ms 792 KB