Submission #126414

# Submission time Handle Problem Language Result Execution time Memory
126414 2019-07-07T16:11:03 Z shafinalam Boat (APIO16_boat) C++14
0 / 100
441 ms 400436 KB
#include <bits/stdc++.h>

using namespace std;
const int mxn = 1e5+5;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<int,int>pii;
#define ff first
#define ss second

pii arr[mxn];
int dp[505][mxn];
int n;

int solve(int pos, int last)
{
    if(pos>=n) return 0;
    if(dp[pos][last]!=-1) return dp[pos][last];

    int ret = 0;
    for(int i = pos+1; i <= n; i++)
    {
        int x = arr[i].ss;
        int st = max(last+1, arr[i].ff);
        for(int r = st; r <= x; r++) ret = (ret+solve(i, r)+1%mod)%mod;
    }
    return dp[pos][last] = ret%mod;
}
int main()
{
    scanf("%d", &n);

    for(int i = 1; i <= n; i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        arr[i] = make_pair(a, b);
    }
    memset(dp, -1, sizeof dp);
    int ans = solve(0, 0)%mod;
    printf("%d\n", ans);
    return 0;
}

Compilation message

boat.cpp: In function 'int main()':
boat.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
boat.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &a, &b);
         ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 439 ms 400376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 439 ms 400376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 441 ms 400436 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 439 ms 400376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -