답안 #782026

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
782026 2023-07-13T14:51:19 Z VadimK Event Hopping (BOI22_events) C++17
0 / 100
266 ms 6348 KB
#include <bits/stdc++.h>
using namespace std;
struct event
{
    int s;
    int f;
    int num;
};
bool cmp (event a, event b)
{
    if (a.f==b.f) return a.s<=b.s;
    return a.f<b.f;
}
int main() {
    int n,q;
    cin>>n>>q;
    event arr[n+1];
    int p[n+1];
    for (int i=1; i<=n; i++)
        cin>>arr[i].s>>arr[i].f;
     for (int i=1; i<=n; i++)
        arr[i].num=i;
    sort (arr+1,arr+n+1,cmp);
     for (int i=1; i<=n; i++)
        p[arr[i].num]=i;
    int ori=1,start[n+1];
    start[1]=1;
     for (int i=1; i<n; i++)
        {
            if (arr[i+1].s<=arr[i].f&&arr[i].f<=arr[i+1].f) start[i+1]=ori;
            else {ori=i+1; start[i+1]=ori;}
        }
    while (q--)
    {
        int a,b,ans=0;
        cin>>a>>b;
        a=p[a]; b=p[b];
        if (start[a]==start[b]&&a<b) cout<<abs(a-b);
        else cout<<"impossible";
        cout<<endl;
    }
}

Compilation message

events.cpp: In function 'int main()':
events.cpp:35:17: warning: unused variable 'ans' [-Wunused-variable]
   35 |         int a,b,ans=0;
      |                 ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 222 ms 5896 KB Output is correct
2 Correct 218 ms 5924 KB Output is correct
3 Correct 214 ms 5824 KB Output is correct
4 Correct 209 ms 6348 KB Output is correct
5 Incorrect 266 ms 6304 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -