Submission #250857

#TimeUsernameProblemLanguageResultExecution timeMemory
250857hackermubBoat (APIO16_boat)C++17
9 / 100
1 ms396 KiB
#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; int add(int a,int b){ return (a+b+MOD)%MOD; } int mul(int a,int b){ return (1LL*a*b)%MOD; } int bigmod(int b,int p){ if(!p) return 1; int x = bigmod(b,p/2); x = mul(x,x); if(p%2) x = mul(x,b); return x; } int vag(int a,int b){ return mul(a,bigmod(b,MOD-2)); } void getseg(vector<pii> &seg,vector<int> &L,vector<int> &R){ vector<pii> v; for(auto x:L) v.push_back({x,0}); for(auto x:R) v.push_back({x,1}); sort(all(v)); v.erase(unique(all(v)),v.end()); for(int i=1;i<sz(v);i++){ if(v[i].second == 1){ if(v[i-1].second == 0) seg.push_back({v[i-1].fi,v[i].fi}); else seg.push_back({v[i-1].fi+1,v[i].fi}); }else if(v[i-1].second == 0){ seg.push_back({v[i-1].fi,v[i].fi-1}); } } } int32_t main(){ ios_base::sync_with_stdio(0),cin.tie(),cout.tie(); int n; cin>>n; vector<int> L(n+1),R(n+1); for(int i=1;i<=n;i++){ cin>>L[i]>>R[i]; } vector<int> dp(n+1); dp[0]=1; int ans=0; for(int i=1;i<=n;i++){ for(int j=0;j<i;j++){ if(L[j]<L[i]) dp[i]=add(dp[i],dp[j]); } ans=add(ans,dp[i]); } // cout<<dp[1]<<" "<<dp[2]<<endl; cout<<ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...