Code Submission Evaluation System Login

# HIIT Open 2016

 Start: 2016-05-28 11:00:00 End: 2016-05-28 16:00:00

CSES - HIIT Open 2016 - Results
History
2016-05-28 14:14:36
 Task: Kaaleppi's puzzle Sender: Ace of Spades Submission time: 2016-05-28 14:14:36 Language: C++ Status: READY Result: ACCEPTED

## Test results

 test verdict time (s) #1 ACCEPTED 0.06 / 5.00 details #2 ACCEPTED 0.06 / 5.00 details #3 ACCEPTED 0.07 / 5.00 details

## Code

```#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int MN = 1111;
const int MOD = 1e9+7;
int ans[MN];
ll dp[3][MN][2]; //e, v

int main(void) {
cin.tie(0);
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(12);
dp[1][0][0] = 1;
ans[1] = 1;
for(int i = 2; i <= 1111; ++i) {
for(int j = 0; j < i; ++j) {
dp[2][j+1][1] += 2*dp[1][j][0];
dp[2][j+1][1] %= MOD;

if(j > 0) {
dp[2][j-1][0] += dp[1][j][0]*j;
dp[2][j-1][0] %= MOD;
}
int q = i-2-j;
dp[2][j][0] += q*dp[1][j][0];
dp[2][j][0] %= MOD;
if(j > 0) {
dp[2][j][1] += dp[1][j][1];
dp[2][j][1] %= MOD;

int w = i-1-j;
dp[2][j][0] += dp[1][j][1]*w;
dp[2][j][0] %= MOD;

dp[2][j+1][1] += dp[1][j][1];
dp[2][j+1][1] %= MOD;

dp[2][j-1][0] += dp[1][j][1] * (j-1);
dp[2][j-1][0] %= MOD;
}
}
for(int j = 0; j < MN; ++j) {
for(int k = 0; k < 2; ++k) {
dp[1][j][k] = dp[2][j][k];
dp[2][j][k] = 0;
}
}
ans[i] = dp[1][0][0];
}
int tt;
cin>>tt;
for(int i = 0; i < tt; ++i) {
int q;
cin>>q;
cout<<ans[q]<<'\n';
}
}
```

## Test details

### Test 1

Verdict: ACCEPTED

input
```20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ...```
view   save

correct output
```1 0 0 2 14 90 646 5242 47622 479306 5296790 63779034 831283558 661506141 203183149 878035968 456796197 911763426 428159996 654286749 ...```
view   save

user output
```1 0 0 2 14 90 646 5242 47622 479306 5296790 63779034 831283558 661506141 203183149 878035968 456796197 911763426 428159996 654286749 ...```
view   save

### Test 2

Verdict: ACCEPTED

input
```20 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 ...```
view   save

correct output
```436438246 92806357 21003215 151460560 326076265 424575830 228692865 201160758 157874096 500271360 735748839 456205691 368613063 327270428 147787261 753800152 993342525 445553830 110101472 711794305 ...```
view   save

user output
```436438246 92806357 21003215 151460560 326076265 424575830 228692865 201160758 157874096 500271360 735748839 456205691 368613063 327270428 147787261 753800152 993342525 445553830 110101472 711794305 ...```
view   save

### Test 3

Verdict: ACCEPTED

input
```20 352 478 99 92 723 608 491 441 38 12 905 907 42 558 218 960 555 381 518 ...```
view   save

correct output
```552481822 246955132 94569313 829032275 94621650 839827603 628162266 795849857 836338597 63779034 646544931 898906053 521761952 479901674 111527011 499723151 220091149 904428111 159152418 190829541 ...```
view   save

user output
```552481822 246955132 94569313 829032275 94621650 839827603 628162266 795849857 836338597 63779034 646544931 898906053 521761952 479901674 111527011 499723151 220091149 904428111 159152418 190829541 ...```
view   save