| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 612513 | hibiki | Event Hopping (BOI22_events) | C++11 | 85 ms | 11252 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
int n, q;
int pw2[20];
pair<int,int> a[100005];
int spa[100005][20];
vector<pair<pair<int, int>, int> > ev;
int main()
{
    pw2[0] = 1;
    for(int i = 1; i < 20; i++)
        pw2[i] = pw2[i - 1] * 2;
    scanf("%d %d", &n, &q);
    for(int i = 0; i < n; i++)
    {
        scanf("%d %d", &a[i].f, &a[i].s);
        ev.pb({{a[i].s, a[i].f}, i});
    }
    sort(all(ev));
    priority_queue<pair<pair<int,int>, int> > pq;
    for(int i = 0; i < n; i++)
    {
        while(!pq.empty() && pq.top().f.s < ev[i].f.s)
            pq.pop();
        if(!pq.empty() && -pq.top().f.f < ev[i].f.s)
            spa[ev[i].s][0] = pq.top().s;
        else
            spa[ev[i].s][0] = -1;
        pq.push({{-ev[i].f.s, ev[i].f.f}, ev[i].s});
        // printf("p: %d %d\n",ev[i].s, spa[ev[i].s][0]);
    }
    for(int j = 1; j < 20; j++)
        for(int i = 0; i < n; i++)
            if(spa[i][j - 1] != -1)
                spa[i][j] = spa[spa[i][j - 1]][j - 1];
    for(int i = 0; i < q; i++)
    {
        int s, t;
        scanf("%d %d", &s, &t);
        s--, t--;
        if(a[s].s > a[t].s)
            printf("impossible\n");
        else
        {
            int ans = 0, cur = t;
            for(int i = 19; i >= 0; i--)
            {
                if(spa[cur][i] != -1 && a[s].s < a[spa[cur][i]].f)
                {
                    ans += pw2[i];
                    cur = spa[cur][i];
                }
            }
            if(spa[cur][0] != -1 && a[spa[cur][0]].f <= a[s].s)
                printf("%d\n", ans + 2);
            else
                printf("impossible\n");
        }
    }
    return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
