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

Submission #172366

Source Code Expand

Copy
```#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

using namespace std;

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
typedef complex<int> P;
typedef pair<int,int> pii;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
template <class F, class T> void convert(const F &f, T &t){	stringstream ss; ss << f; ss >> t;}

const int mod = 1000000007;

ll f(ll x){
if(x == 0 || x == 1) return 1;
return (x * f(x-1)) % mod;
}

bool solve(){
int n;
cin>> n;
vector<int> a(n);
for(int i=0;i<n;i++) cin>> a[i];

ll ans = 1;
int pre = 0, nex = 0;
for(int i=0;i<n;i++){
//		cout<< i<< " a[i]:"<< a[i]<<endl;
if(a[i] == -1){
for(int j=i+1;j<n;j++){
//				cout<< " "<< j;
if(a[j] != -1){
nex = j;
break;
}
}
//			cout<< endl;
ll x = a[nex] - a[pre];
ll y = nex - pre - 1;
ans *= f(x+y)/(f(x)*f(y));
ans %= mod;
//			cout<< ans<< endl;
i = nex;
}
pre = i;
}

cout<< ans<< endl;
return true;
}

int main(){
cout.setf(ios::fixed); cout.precision(10);
solve();
return 0;
}

```

#### Submission Info

Submission Time 2014-05-17 22:31:06+0900 C - タコヤ木 yokabb C++ (G++ 4.6.4) 0 1421 Byte WA 2066 ms 257052 KB

#### Judge Result

Score / Max Score 0 / 0 0 / 50 0 / 30 0 / 20
Status
 AC × 2 MLE × 1
 AC × 11 WA × 3
 AC × 17 WA × 9
 AC × 18 WA × 11 TLE × 5 MLE × 2
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
sample_01.txt AC 27 ms 1028 KB
sample_02.txt AC 34 ms 1116 KB
sample_03.txt MLE 693 ms 257052 KB
subtask1_01.txt AC 31 ms 1056 KB
subtask1_02.txt AC 28 ms 1060 KB
subtask1_03.txt AC 25 ms 1032 KB
subtask1_04.txt WA 28 ms 1028 KB
subtask1_05.txt AC 26 ms 1032 KB
subtask1_06.txt AC 31 ms 1048 KB
subtask1_07.txt WA 33 ms 1036 KB
subtask1_08.txt AC 24 ms 1028 KB
subtask1_09.txt AC 27 ms 1028 KB
subtask1_10.txt AC 29 ms 1056 KB
subtask1_11.txt AC 28 ms 1056 KB
subtask1_12.txt WA 29 ms 1060 KB
subtask2_01.txt AC 25 ms 1032 KB
subtask2_02.txt WA 25 ms 1028 KB
subtask2_03.txt WA 29 ms 1056 KB
subtask2_04.txt AC 28 ms 1032 KB
subtask2_05.txt AC 28 ms 1156 KB
subtask2_06.txt WA 29 ms 1056 KB
subtask2_07.txt WA 30 ms 1056 KB
subtask2_08.txt AC 27 ms 1032 KB
subtask2_09.txt AC 29 ms 1052 KB
subtask2_10.txt WA 28 ms 1032 KB
subtask2_11.txt AC 28 ms 1032 KB
subtask2_12.txt WA 27 ms 1116 KB
subtask3_01.txt AC 30 ms 1032 KB
subtask3_02.txt MLE 708 ms 256924 KB
subtask3_03.txt WA 790 ms 182532 KB
subtask3_04.txt TLE 2040 ms 27908 KB
subtask3_05.txt WA 1755 ms 73608 KB
subtask3_06.txt TLE 2044 ms 31836 KB
subtask3_07.txt MLE 734 ms 256920 KB
subtask3_08.txt AC 31 ms 1036 KB
subtask3_09.txt AC 28 ms 1004 KB
subtask3_10.txt TLE 2051 ms 58908 KB
subtask3_11.txt TLE 2066 ms 157320 KB
subtask3_12.txt TLE 2046 ms 45732 KB