Submission #739805

#TimeUsernameProblemLanguageResultExecution timeMemory
739805Magikarp4000Boat (APIO16_boat)C++17
9 / 100
1168 ms524288 KiB
#include <bits/stdc++.h> using namespace std; #define OPTM ios_base::sync_with_stdio(0); cin.tie(0); #define INF int64_t(1e9+7) #define ln '\n' #define ll long long #define ull unsigned long long #define ui unsigned int #define us unsigned short #define FOR(i,s,n) for (int i = s; i < n; i++) #define FORR(i,n,s) for (int i = n; i > s; i--) #define FORX(u, arr) for (auto u : arr) #define PB push_back #define in(v,x) (v.find(x) != v.end()) #define F first #define S second #define PII pair<int, int> #define PLL pair<ll, ll> #define UM unordered_map #define US unordered_set #define PQ priority_queue #define ALL(v) v.begin(), v.end() const ll LLINF = 1e18+1; // #define int long long const int MAXN = 5e2+1, MAXX = 1e6+10; int n; int l[MAXN], r[MAXN]; vector<int> uncc; UM<int,int> cc; US<int> vis; int dp[MAXN][MAXX]; void add(int x) { if (!vis.count(x)) { vis.insert(x); uncc.PB(x); } } signed main() { OPTM; cin >> n; FOR(i,1,n+1) { cin >> l[i] >> r[i]; FOR(j,l[i],r[i]+1) add(j); } uncc.PB(0); sort(ALL(uncc)); int vn = uncc.size(); FOR(i,0,vn) cc[uncc[i]] = i; FOR(i,1,n+1) { int cl = cc[l[i]], cr = cc[r[i]]; FOR(j,cl,cr+1) { dp[i][j] = 1; FOR(k,1,i) dp[i][j] = (dp[i][j]+dp[k][j-1])%INF; } FOR(j,1,vn) dp[i][j] = (dp[i][j]+dp[i][j-1])%INF; } // FOR(i,1,n+1) { // FOR(j,0,vn) cout << dp[i][j] << ' '; // cout << ln; // } int res = 0; FOR(i,1,n+1) res = (res+dp[i][vn-1])%INF; cout << res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...