답안 #753834

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
753834 2023-06-06T07:09:42 Z Luca7 Boat (APIO16_boat) C++17
0 / 100
2000 ms 468 KB
#include <iostream>
#include<vector>
#pragma GCC optimize("O3","unroll-loops")
using namespace std;

#define limit 1000000007
typedef long long ll;

//ifstream cin("data.in");
//ofstream cout("data.out");

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);

    /*cout << "500\n";
    for (int i = 0; i < 500; i++) {
        cout << "5 5\n";
    }
    
    return 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:45:11: warning: unused variable 'j' [-Wunused-variable]
   45 |     ll i, j, nr, n,a,b;
      |           ^
boat.cpp:45:14: warning: unused variable 'nr' [-Wunused-variable]
   45 |     ll i, j, nr, n,a,b;
      |              ^~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2090 ms 468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2090 ms 468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2056 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2090 ms 468 KB Time limit exceeded
2 Halted 0 ms 0 KB -