Submission #753831

# Submission time Handle Problem Language Result Execution time Memory
753831 2023-06-06T07:02:06 Z Luca7 Boat (APIO16_boat) C++17
0 / 100
2000 ms 460 KB
#include <iostream>
#include<vector>
#pragma GCC optimize("O3","unroll-loops")
using namespace std;

#define limit 1000000007
typedef long long ll;

struct School {
    ll a, b;
};
vector<School> schools;

ll res = 0;
void solve(ll n, ll i,ll minn) {
    if (i == n) {
        res++;
        if (res == limit)
            res = 0;
        return;
    }

    solve(n, i + 1, minn);
    for (int j = max(minn, schools[i].a); j <= schools[i].b; j++) {
        solve(n, i + 1, j + 1);
    }

}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll i, j, nr, n,a,b;

    cin >> n;
    for (i = 0; i < n; i++) {
        cin >> a >> b;
        schools.push_back({a,b});
    }
    
    solve(n, 0, 0);
    res--;
    if (res == -1) {
        res = limit;
    }
    cout << res;

    return 0;
}

Compilation message

boat.cpp: In function 'int main()':
boat.cpp:36:11: warning: unused variable 'j' [-Wunused-variable]
   36 |     ll i, j, nr, n,a,b;
      |           ^
boat.cpp:36:14: warning: unused variable 'nr' [-Wunused-variable]
   36 |     ll i, j, nr, n,a,b;
      |              ^~
# Verdict Execution time Memory Grader output
1 Execution timed out 2080 ms 460 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2080 ms 460 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2061 ms 316 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2080 ms 460 KB Time limit exceeded
2 Halted 0 ms 0 KB -