Contest Duration: - (local time) (90 minutes) Back to Home

Submission #173154

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 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;
}
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)%mod;

}
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<<endl;
return 0;
}```

#### Submission Info

Submission Time 2014-05-19 21:11:41+0900 C - タコヤ木 togatoga C++ (G++ 4.6.4) 100 1481 Byte AC 29 ms 936 KB

#### Judge Result

Score / Max Score 0 / 0 50 / 50 30 / 30 20 / 20
Status
 AC × 3
 AC × 14
 AC × 26
 AC × 36
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
sample_01.txt AC 21 ms 792 KB
sample_02.txt AC 21 ms 796 KB
sample_03.txt AC 21 ms 796 KB
subtask1_01.txt AC 29 ms 936 KB
subtask1_02.txt AC 21 ms 780 KB
subtask1_03.txt AC 21 ms 792 KB
subtask1_04.txt AC 22 ms 916 KB
subtask1_05.txt AC 21 ms 796 KB
subtask1_06.txt AC 22 ms 796 KB
subtask1_07.txt AC 22 ms 804 KB
subtask1_08.txt AC 21 ms 796 KB
subtask1_09.txt AC 21 ms 912 KB
subtask1_10.txt AC 21 ms 920 KB
subtask1_11.txt AC 22 ms 796 KB
subtask1_12.txt AC 21 ms 796 KB
subtask2_01.txt AC 22 ms 924 KB
subtask2_02.txt AC 21 ms 924 KB
subtask2_03.txt AC 21 ms 916 KB
subtask2_04.txt AC 21 ms 920 KB
subtask2_05.txt AC 21 ms 924 KB
subtask2_06.txt AC 22 ms 792 KB
subtask2_07.txt AC 23 ms 924 KB
subtask2_08.txt AC 22 ms 916 KB
subtask2_09.txt AC 24 ms 920 KB
subtask2_10.txt AC 23 ms 792 KB
subtask2_11.txt AC 21 ms 796 KB
subtask2_12.txt AC 21 ms 808 KB
subtask3_01.txt AC 21 ms 924 KB
subtask3_02.txt AC 22 ms 916 KB
subtask3_03.txt AC 21 ms 920 KB
subtask3_04.txt AC 22 ms 808 KB
subtask3_05.txt AC 22 ms 796 KB
subtask3_06.txt AC 22 ms 924 KB
subtask3_07.txt AC 22 ms 924 KB
subtask3_08.txt AC 22 ms 808 KB
subtask3_09.txt AC 22 ms 916 KB
subtask3_10.txt AC 22 ms 920 KB
subtask3_11.txt AC 24 ms 788 KB
subtask3_12.txt AC 22 ms 812 KB