답안 #550633

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
550633 2022-04-18T18:02:30 Z Vladth11 Calvinball championship (CEOI15_teams) C++14
70 / 100
29 ms 19148 KB
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "

using namespace std;
typedef long long ll;
typedef pair <int, int> pii;

const ll NMAX = 1001;
const ll VMAX = 10001;
const ll INF = (1LL << 55);
const ll MOD = 1000007;
const ll BLOCK = 1000000;
const ll base = 1000000001;
const ll nr_of_bits = 18;

int dp[NMAX][NMAX][3];
int v[NMAX];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, i, j;
    cin >> n;
    for(i = 1; i <= n; i++){
        cin >> v[i];
    }
    dp[0][0][1] = 1;
    int sum = 0;
    for(i = 1; i <= n; i++){
        for(j = 1; j <= i; j++){
            /// Nu deschid culoare noua
            dp[i][j][0] = (dp[i - 1][j][0] * j) % MOD;
            dp[i][j][0] += (dp[i - 1][j][1] * min(j, v[i] - 1)) % MOD;
            dp[i][j][0] %= MOD;
            if(j >= v[i])
                dp[i][j][1] = dp[i - 1][j][1];
            dp[i][j][2] = (dp[i - 1][j][2] * j) % MOD;
            dp[i][j][2] += (dp[i - 1][j][1] * max(0, j - v[i])) % MOD;
            dp[i][j][2] %= MOD;
            /// Deschid o culoare noua
            dp[i][j][0] += dp[i - 1][j - 1][0];
            dp[i][j][0] %= MOD;
            if(j < v[j]){
                dp[i][j][0] += dp[i - 1][j - 1][1];
                dp[i][j][0] %= MOD;
            }
            if(j == v[i]){
                dp[i][j][1] += dp[i - 1][j - 1][1];
                dp[i][j][1] %= MOD;
            }
            dp[i][j][2] += dp[i - 1][j - 1][2];
            dp[i][j][2] %= MOD;
            if(j > v[i]){
                dp[i][j][2] += dp[i - 1][j - 1][1] % MOD;
                dp[i][j][2] %= MOD;
            }
            if(i == n){
                sum += dp[i][j][0];
                sum %= MOD;
            }
        }
    }
    cout << sum + 1;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 724 KB Output is correct
2 Correct 1 ms 716 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3784 KB Output is correct
2 Correct 4 ms 3796 KB Output is correct
3 Correct 5 ms 3696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 9532 KB Output is correct
2 Correct 13 ms 9428 KB Output is correct
3 Correct 12 ms 9552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 24 ms 19148 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 29 ms 19100 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 27 ms 19088 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -