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

Submission #173150

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 + 1;
while(last < N&&A[last]==-1){
last++;
}
ans =(ans*C(A[last] - A[pre -1] + last - pre,last - pre))%mod;
i = last + 1;
}
}
cout <<ans%mod<<endl;
return 0;
}```

Submission Info

Submission Time 2014-05-19 21:02:12+0900 C - タコヤ木 togatoga C++ (G++ 4.6.4) 0 1547 Byte WA 24 ms 932 KB

Judge Result

Score / Max Score 0 / 0 0 / 50 0 / 30 0 / 20
Status
 AC × 3
 AC × 7 WA × 7
 AC × 12 WA × 14
 AC × 15 WA × 21
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 924 KB
sample_02.txt AC 21 ms 924 KB
sample_03.txt AC 21 ms 796 KB
subtask1_01.txt AC 21 ms 920 KB
subtask1_02.txt AC 21 ms 796 KB
subtask1_03.txt AC 22 ms 924 KB
subtask1_04.txt WA 21 ms 924 KB
subtask1_05.txt WA 22 ms 928 KB
subtask1_06.txt WA 21 ms 920 KB
subtask1_07.txt AC 21 ms 796 KB
subtask1_08.txt AC 20 ms 812 KB
subtask1_09.txt WA 21 ms 924 KB
subtask1_10.txt WA 21 ms 924 KB
subtask1_11.txt WA 20 ms 924 KB
subtask1_12.txt WA 21 ms 924 KB
subtask2_01.txt AC 20 ms 804 KB
subtask2_02.txt AC 21 ms 800 KB
subtask2_03.txt AC 21 ms 804 KB
subtask2_04.txt WA 20 ms 796 KB
subtask2_05.txt WA 23 ms 792 KB
subtask2_06.txt WA 20 ms 920 KB
subtask2_07.txt AC 22 ms 932 KB
subtask2_08.txt AC 21 ms 928 KB
subtask2_09.txt WA 21 ms 800 KB
subtask2_10.txt WA 23 ms 920 KB
subtask2_11.txt WA 23 ms 796 KB
subtask2_12.txt WA 21 ms 800 KB
subtask3_01.txt AC 20 ms 796 KB
subtask3_02.txt AC 20 ms 796 KB
subtask3_03.txt AC 20 ms 924 KB
subtask3_04.txt WA 22 ms 732 KB
subtask3_05.txt WA 21 ms 804 KB
subtask3_06.txt WA 21 ms 920 KB
subtask3_07.txt AC 21 ms 924 KB
subtask3_08.txt AC 23 ms 732 KB
subtask3_09.txt WA 24 ms 796 KB
subtask3_10.txt WA 21 ms 800 KB
subtask3_11.txt WA 22 ms 800 KB
subtask3_12.txt WA 21 ms 800 KB