Submission #523737

# Submission time Handle Problem Language Result Execution time Memory
523737 2022-02-08T05:41:04 Z vonatlus Boat (APIO16_boat) C++17
9 / 100
2000 ms 524292 KB
/// adil sultanov | vonat1us 

#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:36777216")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
#define all(z) (z).begin(), (z).end()
 
using namespace std;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7; 
const int INF = 1e9 + 1e2;
  
void fin() {
#ifdef AM
    freopen(".in", "r", stdin);
#endif        
}                   

const bool flag = 0;

const int N = 510;

int add(int a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
    return a;
}

int a[N], b[N], len[N];

unordered_map<int, int> dp[N];

void ma1n() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i] >> b[i];
        len[i] = b[i]-a[i]+1;
    }
    if (n == 1) {
        cout << b[1]-a[1]+1, exit(0);
    }
    for (int i = 1; i <= n; ++i) {
        dp[i][0] = add(dp[i-1][0], dp[i-1][b[i-1]]);
        for (int x = a[i]; x <= b[i]; ++x) {
            for (int j = 1; j < i; ++j) {
                int r = min(b[j], x-1);
                if (a[j] <= r) {
                    dp[i][x] = add(dp[i][x], dp[j][r]);
                }
            }
        }            
        for (int x = a[i]; x <= b[i]; ++x) {
            if (x+1 <= b[i]) dp[i][x+1] = add(dp[i][x+1], dp[i][x]);
            dp[i][x] = add(dp[i][x], x-a[i]+1);
        }
    }
    cout << add(dp[n][0], dp[n][b[n]]);
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), fin();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        ma1n(); 
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 3 ms 332 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
6 Correct 5 ms 332 KB Output is correct
7 Correct 6 ms 332 KB Output is correct
8 Correct 5 ms 396 KB Output is correct
9 Correct 5 ms 416 KB Output is correct
10 Correct 5 ms 332 KB Output is correct
11 Correct 5 ms 332 KB Output is correct
12 Correct 6 ms 428 KB Output is correct
13 Correct 6 ms 332 KB Output is correct
14 Correct 5 ms 332 KB Output is correct
15 Correct 6 ms 432 KB Output is correct
16 Correct 4 ms 332 KB Output is correct
17 Correct 4 ms 332 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 3 ms 332 KB Output is correct
20 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 3 ms 332 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
6 Correct 5 ms 332 KB Output is correct
7 Correct 6 ms 332 KB Output is correct
8 Correct 5 ms 396 KB Output is correct
9 Correct 5 ms 416 KB Output is correct
10 Correct 5 ms 332 KB Output is correct
11 Correct 5 ms 332 KB Output is correct
12 Correct 6 ms 428 KB Output is correct
13 Correct 6 ms 332 KB Output is correct
14 Correct 5 ms 332 KB Output is correct
15 Correct 6 ms 432 KB Output is correct
16 Correct 4 ms 332 KB Output is correct
17 Correct 4 ms 332 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 3 ms 332 KB Output is correct
20 Correct 3 ms 332 KB Output is correct
21 Execution timed out 2075 ms 19456 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1683 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 3 ms 332 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
6 Correct 5 ms 332 KB Output is correct
7 Correct 6 ms 332 KB Output is correct
8 Correct 5 ms 396 KB Output is correct
9 Correct 5 ms 416 KB Output is correct
10 Correct 5 ms 332 KB Output is correct
11 Correct 5 ms 332 KB Output is correct
12 Correct 6 ms 428 KB Output is correct
13 Correct 6 ms 332 KB Output is correct
14 Correct 5 ms 332 KB Output is correct
15 Correct 6 ms 432 KB Output is correct
16 Correct 4 ms 332 KB Output is correct
17 Correct 4 ms 332 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 3 ms 332 KB Output is correct
20 Correct 3 ms 332 KB Output is correct
21 Execution timed out 2075 ms 19456 KB Time limit exceeded
22 Halted 0 ms 0 KB -