Submission #124246

# Submission time Handle Problem Language Result Execution time Memory
124246 2019-07-02T21:52:09 Z amiratou Boat (APIO16_boat) C++14
0 / 100
14 ms 4344 KB
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int B[501],A[501];
v vec;
int n;
int dp[501][1005];
int solve(int i,int last){
    if(i==n)
        return 1;
    //debugs(i,vec[last])
    if(dp[i][last]!=-1)
        return dp[i][last];
    int ans=0;
    ans+=solve(i+1,last);
    if(vec[last]<A[i])
        ans=((ans%MOD)+(((B[i]-A[i]+1)*(solve(i+1,lower_bound(all(vec),B[i])-vec.begin())))%MOD))%MOD;
    else
        ans=((ans%MOD)+(((((B[i]-A[i])*(B[i]-A[i]+1))/2)*(solve(i+1,lower_bound(all(vec),B[i])-vec.begin())))%MOD))%MOD;
    return dp[i][last]=ans%MOD;
}
 main(){
    boost;
    memset(dp,-1,sizeof dp);
    set<int> myset;
    cin>>n;
    for (int i = 0; i < n; ++i)
    {
        cin>>A[i]>>B[i];
        myset.insert(A[i]);
        myset.insert(B[i]);
    }
    vec.pb(0);
    for(auto it:myset)
        vec.pb(it);
    cout<<solve(0,0);
    return 0;
}
//long long
//array bounds
//special cases
//binary search

Compilation message

boat.cpp:41:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  main(){
       ^
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 4344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 4344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 4344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 4344 KB Output isn't correct
2 Halted 0 ms 0 KB -