답안 #745908

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
745908 2023-05-21T09:34:08 Z vjudge1 Event Hopping (BOI22_events) C++17
0 / 100
170 ms 8772 KB
#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, pair<int, int>> m;
	int segment = 1;
	for (int i = 0; i < n; i++) {
		if (i && events[i-1].e < events[i].s) segment++;
		m[events[i].idx] = {i, segment};
	}
	while (q--) {
		int a, b; cin >> a >> b;
		if (m[a].second != m[b].second) {
			cout << "impossible\n";
			continue;
		}
		a = m[a].first; b = m[b].first;
		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 92 ms 8272 KB Output is correct
2 Correct 133 ms 8288 KB Output is correct
3 Correct 170 ms 8284 KB Output is correct
4 Correct 107 ms 8772 KB Output is correct
5 Correct 143 ms 8688 KB Output is correct
6 Incorrect 151 ms 8568 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -