# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
659825 | 600Mihnea | Event Hopping (BOI22_events) | C++17 | 0 ms | 212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
bool home = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = (int) 1e5 + 7;
int n;
int q;
struct T {
int l;
int r;
};
T v[N];
int dp[N];
int main() {
if (!home) {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
} else {
freopen("input.txt", "r", stdin);
}
cin >> n >> q;
for (int i = 1; i <= n; i++) {
cin >> v[i].l >> v[i].r;
}
for (int iq = 1; iq <= q; iq++) {
int ff, ss;
cin >> ff >> ss;
for (int i = 1; i <= n; i++) {
dp[i] = -1;
}
queue<int> q;
q.push(ff);
dp[ff] = 0;
while (!q.empty()) {
int a = q.front();
q.pop();
for (int b = 1; b <= n; b++) {
if (v[b].l <= v[a].r && v[a].r <= v[b].r && dp[b] == -1) {
dp[b] = 1 + dp[a];
q.push(b);
}
}
}
if (dp[ss] == -1) {
cout << "impossible\n";
continue;
}
cout << dp[ss] << "\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... |