Submission #124208

# Submission time Handle Problem Language Result Execution time Memory
124208 2019-07-02T16:35:58 Z AyaBenSaad Boat (APIO16_boat) C++14
0 / 100
2000 ms 38396 KB
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD = 1e9 + 7;
const int M = 5e2 + 2;
const int N = 1e2 + 6;
int n, a[M], b[M];
set <int> s;
vector <int> v;
map <pair<pair <int, int>, int>, int> dp;

int solve (int id, int last, int ok) {
    if (id >= n) return ((last != a[0] && ok == 2)? 1 : 0);
    int &ret = dp[{{id,last}, ok}];
    if (ret != 0) return ret;
    ret = solve(id+1, last, ok);
    for (int i = max (a[id], last+1); i <= b[id]; i++) {
        ret = (1ll*ret + 1ll*solve (id+1, i, max (ok+1, 2)) + 1) % MOD;
    }
    return ret;
}

int main () {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &a[i], &b[i]);
        s.insert (a[i]);
        s.insert (b[i]);
    }
    for (int i : s) {
        v.push_back(i);
    }
    printf("%d\n", solve (0, a[0] , 0));
}
//1 2
//2 3


Compilation message

boat.cpp: In function 'int main()':
boat.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
boat.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &a[i], &b[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 405 ms 38396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 405 ms 38396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2058 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 405 ms 38396 KB Output isn't correct
2 Halted 0 ms 0 KB -