Submission #400049

# Submission time Handle Problem Language Result Execution time Memory
400049 2021-05-07T08:54:06 Z marvenlee Boat (APIO16_boat) C++14
0 / 100
256 ms 524292 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
typedef string str;
typedef vector<ll>  vl;
typedef vector< vector<ll> > vvl;
typedef vector<ii> vii;
typedef vector< vector<ii> > vvii;
typedef vector<iii> viii;
typedef vector< vector<iii> > vviii;
typedef vector<str>  vs;
typedef vector< vector<str> > vvs;
typedef long double ld;
typedef priority_queue<long long> pq;
/*
Hiiden Function
__gcd()
__builtin_clz(x)
__builtin_ctz(x)
__builtin_popcount(x)

*/

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
// debugging Function
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}


#define LSOne(S) ( (S) & -(S))
#define elif else if
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define FOR(i,v) for(auto i:v)
#define rep(i, begin, end) for(__typeof(end) i=(begin) -((begin)>(end));i!=(end)-((begin)>(end)); i+= 1 - 2*((begin)>(end)))
#define repin(i,a,b,x) for(int i=(a);i<(b);i+=x)
#define repnin(i,a,b,x) for(int i=(a);i<=(b);i+=x)
#define MAX(a,b) a=max(a,b)
#define MIN(a,b) a=min(a,b)
#define fbo find_by_order
#define ook order_of_key
#define ALL(v) v.begin(),v.end()
#define FILL(arr,x) memset(arr,x,sizeof arr);
// if else int i = (number <0) ? 1:0 -  if (number <0) i=1 else 0
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ld EPS = 1e-9;

int main()
{ 
 //ios_base::sync_with_stdio(0);
 //cin.tie(0);
 //cout.tie(0);
 //freopen("UT.txt","w",stdout);
 int n;
 cin >> n;
 ll a[n+1];
 ll b[n+1];
 rep(i,1,n+1) cin >> a[i] >> b[i];
 a[0]=INF;
 b[0]= INF;
 vvl dp(n+1,vl());
 dp[0].pb(0);

 rep(i,1,n+1){
   dp[i].assign(b[i]-a[i]+1,0);
   rep(k,a[i],b[i]+1){
      if(k!=a[i]) dp[i][k-a[i]]= dp[i][k-1-a[i]] +1;
      
      rep(j,1,i){
        if(k<=a[j]) continue;
        if(k>b[j]) dp[i][k-a[i]]+=dp[j][b[j]-a[j]];
        else{
          dp[i][k-a[i]] += dp[j][k-a[j]-1];
        }
        dp[i][k-a[i]]%=MOD;
      } 
   
      
   }
 }
  int ans=0;
  rep(i,1,n+1){
    ans += *(dp[i].end()--);
  }
  cout << ans;
}
  
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 256 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -