답안 #1094719

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1094719 2024-09-30T10:42:15 Z crafticat Event Hopping (BOI22_events) C++17
10 / 100
1500 ms 3080 KB
#include "bits/stdc++.h"

using namespace std;
template<typename T>
using V = vector<T>;
using vi = V<int>;
using pi = pair<int,int>;
#define f first
#define s second

#define F0R(i, n) for(int i = 0; i < n;i++)
#define FOR(i,a, n) for(int i = a; i < n;i++)
#define pb push_back
#define all(x) begin(x), end(x)
#define each(x, y) for(auto &x : y)
constexpr int INF = 1e9 + 2;

pi binarySearch(V<pi> &stack, int point) {
    auto it = std::upper_bound(stack.begin(), stack.end(), make_pair(point,INF)); // Point to before or at point
    if (it == stack.begin()) return {0,0};
    it--;
    return {it - stack.begin() + 1, it->s};
}

int getImp(V<pi> &stack) {
    return (stack.empty() ? 0 : stack.back().s);
}
#define ckmax(a,b) a = max(a,b)

int main() {
    int n, q; cin >> n >> q;

    V<pi> edges;

    F0R(i, n) {
        int a, b; cin >> a >> b;
        edges.pb({a,b});
    }
    F0R(i, q) {
        int a, b; cin >> a >> b;
        a--;
        b--;

        int point = edges[a].s;
        int ans = 0;

        while (point < edges[b].f) {
            int bestNext = point;
            ans++;
            F0R(j, n) {
                if (edges[j].f <= point && edges[j].s <= edges[b].s) ckmax(bestNext, edges[j].s);
            }
            if (bestNext == point) break;
            point = bestNext;
        }
        if (a == b) {
            cout << "0\n";
            continue;
        }
        if (point < edges[b].f || point > edges[b].s) {
            cout << "impossible\n";
            continue;
        }

        cout << ans + 1 << "\n";
    }


    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 1558 ms 1492 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 86 ms 348 KB Output is correct
4 Correct 11 ms 344 KB Output is correct
5 Correct 17 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 448 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 86 ms 348 KB Output is correct
4 Correct 11 ms 344 KB Output is correct
5 Correct 17 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 448 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 101 ms 348 KB Output is correct
13 Correct 11 ms 344 KB Output is correct
14 Correct 19 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 464 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Execution timed out 1597 ms 648 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 86 ms 348 KB Output is correct
4 Correct 11 ms 344 KB Output is correct
5 Correct 17 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 448 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 432 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 85 ms 348 KB Output is correct
13 Correct 12 ms 344 KB Output is correct
14 Correct 21 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Execution timed out 1597 ms 3080 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1552 ms 1324 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Execution timed out 1558 ms 1492 KB Time limit exceeded
3 Halted 0 ms 0 KB -