Submission #251788

# Submission time Handle Problem Language Result Execution time Memory
251788 2020-07-22T10:08:46 Z hackermub Boat (APIO16_boat) C++17
9 / 100
392 ms 524292 KB
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define pii pair<int,int>
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pb push_back
#define sz(v) (int)v.size()
const int MOD = 1e9+7;
const int64_t INF = 1e18;

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie();
    //If you hack my code , You are gay;
    int n;
    cin>>n;
    vector<int> L(n),R(n);
    vector<int> v={0};
    for(int i=0;i<n;i++){
        cin>>L[i]>>R[i];
        for(int j=L[i];j<=R[i];j++){
            v.push_back(j);
        }
    }
    sort(all(v));
    v.erase(unique(all(v)),v.end());
    for(int i=0;i<n;i++){
        L[i] = lower_bound(all(v),L[i])-v.begin();
        R[i] = lower_bound(all(v),R[i])-v.begin();
        //cout<<L[i]<<" "<<R[i]<<"\n";
    }
    vector<vector<int>> dp(n+1,vector<int>(sz(v)+1,0)),sum(n+1,vector<int>(sz(v)+1,0));
    dp[0][0]=1;
    for(int i=0;i<sz(v);i++) sum[0][i] = 1;
    for(int i=1;i<=n;i++){
        for(int j=L[i-1];j<=R[i-1];j++){
            dp[i][j] = (dp[i][j] + sum[i-1][j-1])%MOD;
        }
        sum[i][0] = 1;
        for(int j=1;j<sz(v);j++){
            sum[i][j] = (dp[i][j] + sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1])%MOD;
        }
    }
    cout<<(sum[n][sz(v)-1]-1+MOD)%MOD;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4352 KB Output is correct
2 Correct 4 ms 4352 KB Output is correct
3 Correct 4 ms 4352 KB Output is correct
4 Correct 4 ms 4352 KB Output is correct
5 Correct 6 ms 4352 KB Output is correct
6 Correct 4 ms 4352 KB Output is correct
7 Correct 4 ms 4352 KB Output is correct
8 Correct 5 ms 4352 KB Output is correct
9 Correct 5 ms 4352 KB Output is correct
10 Correct 5 ms 4352 KB Output is correct
11 Correct 5 ms 4352 KB Output is correct
12 Correct 5 ms 4352 KB Output is correct
13 Correct 4 ms 4364 KB Output is correct
14 Correct 5 ms 4352 KB Output is correct
15 Correct 5 ms 4352 KB Output is correct
16 Correct 2 ms 1152 KB Output is correct
17 Correct 1 ms 1152 KB Output is correct
18 Correct 2 ms 1152 KB Output is correct
19 Correct 2 ms 1152 KB Output is correct
20 Correct 1 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4352 KB Output is correct
2 Correct 4 ms 4352 KB Output is correct
3 Correct 4 ms 4352 KB Output is correct
4 Correct 4 ms 4352 KB Output is correct
5 Correct 6 ms 4352 KB Output is correct
6 Correct 4 ms 4352 KB Output is correct
7 Correct 4 ms 4352 KB Output is correct
8 Correct 5 ms 4352 KB Output is correct
9 Correct 5 ms 4352 KB Output is correct
10 Correct 5 ms 4352 KB Output is correct
11 Correct 5 ms 4352 KB Output is correct
12 Correct 5 ms 4352 KB Output is correct
13 Correct 4 ms 4364 KB Output is correct
14 Correct 5 ms 4352 KB Output is correct
15 Correct 5 ms 4352 KB Output is correct
16 Correct 2 ms 1152 KB Output is correct
17 Correct 1 ms 1152 KB Output is correct
18 Correct 2 ms 1152 KB Output is correct
19 Correct 2 ms 1152 KB Output is correct
20 Correct 1 ms 1152 KB Output is correct
21 Correct 84 ms 48080 KB Output is correct
22 Correct 86 ms 47956 KB Output is correct
23 Correct 83 ms 47568 KB Output is correct
24 Correct 89 ms 48212 KB Output is correct
25 Correct 91 ms 48344 KB Output is correct
26 Correct 78 ms 38356 KB Output is correct
27 Correct 76 ms 38612 KB Output is correct
28 Correct 77 ms 38612 KB Output is correct
29 Correct 76 ms 38616 KB Output is correct
30 Runtime error 323 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
31 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 392 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4352 KB Output is correct
2 Correct 4 ms 4352 KB Output is correct
3 Correct 4 ms 4352 KB Output is correct
4 Correct 4 ms 4352 KB Output is correct
5 Correct 6 ms 4352 KB Output is correct
6 Correct 4 ms 4352 KB Output is correct
7 Correct 4 ms 4352 KB Output is correct
8 Correct 5 ms 4352 KB Output is correct
9 Correct 5 ms 4352 KB Output is correct
10 Correct 5 ms 4352 KB Output is correct
11 Correct 5 ms 4352 KB Output is correct
12 Correct 5 ms 4352 KB Output is correct
13 Correct 4 ms 4364 KB Output is correct
14 Correct 5 ms 4352 KB Output is correct
15 Correct 5 ms 4352 KB Output is correct
16 Correct 2 ms 1152 KB Output is correct
17 Correct 1 ms 1152 KB Output is correct
18 Correct 2 ms 1152 KB Output is correct
19 Correct 2 ms 1152 KB Output is correct
20 Correct 1 ms 1152 KB Output is correct
21 Correct 84 ms 48080 KB Output is correct
22 Correct 86 ms 47956 KB Output is correct
23 Correct 83 ms 47568 KB Output is correct
24 Correct 89 ms 48212 KB Output is correct
25 Correct 91 ms 48344 KB Output is correct
26 Correct 78 ms 38356 KB Output is correct
27 Correct 76 ms 38612 KB Output is correct
28 Correct 77 ms 38612 KB Output is correct
29 Correct 76 ms 38616 KB Output is correct
30 Runtime error 323 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
31 Halted 0 ms 0 KB -