#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100001;
const int K = 20;
struct Event {
int s, e, idx;
};
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int n, q; cin >> n >> q;
vector<Event> events(n);
int j = 0;
for (Event &i : events) {
cin >> i.s >> i.e;
i.idx = ++j;
}
sort(events.begin(), events.end(), [&](Event a, Event b) {
return a.s < b.s;
});
map<int, int> m;
for (int i = 0; i < n; i++) {
m[events[i].idx] = i;
}
while (q--) {
int a, b; cin >> a >> b;
a = m[a]; b = m[b];
if (a > b) cout << "impossible\n";
else cout << b-a << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
85 ms |
6688 KB |
Output is correct |
2 |
Correct |
113 ms |
6716 KB |
Output is correct |
3 |
Correct |
131 ms |
6672 KB |
Output is correct |
4 |
Incorrect |
117 ms |
6752 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |