# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
405820 |
2021-05-16T23:23:34 Z |
gevacrt |
Boat (APIO16_boat) |
C++17 |
|
483 ms |
524292 KB |
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define INF INT_MAX
#define MOD 1000000007
#define all(x) x.begin(), x.end()
vii A;
vector<gp_hash_table<int, ll>> dp;
void solve(int x, int C){
auto &v = dp[x][C];
if(x == 0) v = 2;
else{
v += dp[x-1][min(C-1, A[x-1].second)]; v %= MOD;
v += dp[x-1][min(C, A[x-1].second)]; v %= MOD;
}
if(dp[x].find(C-1) != dp[x].end()){
v += dp[x][C-1]; v %= MOD;
if(x == 0) v -= 1, v %= MOD;
else v -= dp[x-1][min(C-1, A[x-1].second)], v %= MOD;
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int N; cin >> N;
A.resize(N);
for(auto &[l, r] : A)
cin >> l >> r;
dp.resize(N);
for(int x = 0; x < N; x++){
for(auto [l, r] = A[x]; l <= r; l++)
solve(x, l);
}
cout << (dp[N-1][A.back().second]-1+MOD)%MOD << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
483 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |