답안 #1000388

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1000388 2024-06-17T11:04:15 Z pcc Event Hopping (BOI22_events) C++17
10 / 100
71 ms 4572 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>


const int mxn = 1010;
pii arr[mxn];
vector<int> paths[mxn];
int N,Q;
int dist[mxn];
queue<int> q;

void BFS(int s){
	fill(dist,dist+mxn,mxn);
	q.push(s);
	dist[s] = 0;
	while(!q.empty()){
		auto now = q.front();
		q.pop();
		for(auto nxt:paths[now]){
			if(dist[nxt]>dist[now]+1)dist[nxt] = dist[now]+1,q.push(nxt);
		}
	}
	return;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>N>>Q;
	for(int i = 1;i<=N;i++){
		cin>>arr[i].fs>>arr[i].sc;
	}
	for(int i = 1;i<=N;i++){
		for(int j = 1;j<=N;j++){
			if(i == j)continue;
			if(arr[i].fs<=arr[j].sc&&arr[j].sc<=arr[i].sc)paths[j].push_back(i);
		}
	}
	while(Q--){
		int s,t;
		cin>>s>>t;
		BFS(s);
		if(dist[t]>=mxn)cout<<"impossible\n";
		else cout<<dist[t]<<'\n';
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1 ms 604 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 3 ms 500 KB Output is correct
6 Correct 8 ms 1276 KB Output is correct
7 Correct 15 ms 2140 KB Output is correct
8 Correct 15 ms 3416 KB Output is correct
9 Correct 71 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 3 ms 500 KB Output is correct
6 Correct 8 ms 1276 KB Output is correct
7 Correct 15 ms 2140 KB Output is correct
8 Correct 15 ms 3416 KB Output is correct
9 Correct 71 ms 4444 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 4 ms 348 KB Output is correct
13 Correct 3 ms 348 KB Output is correct
14 Correct 2 ms 508 KB Output is correct
15 Correct 7 ms 1372 KB Output is correct
16 Correct 15 ms 2140 KB Output is correct
17 Correct 16 ms 3164 KB Output is correct
18 Correct 71 ms 4568 KB Output is correct
19 Runtime error 1 ms 604 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 3 ms 500 KB Output is correct
6 Correct 8 ms 1276 KB Output is correct
7 Correct 15 ms 2140 KB Output is correct
8 Correct 15 ms 3416 KB Output is correct
9 Correct 71 ms 4444 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 3 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 3 ms 348 KB Output is correct
15 Correct 7 ms 1440 KB Output is correct
16 Correct 19 ms 2652 KB Output is correct
17 Correct 15 ms 3164 KB Output is correct
18 Correct 71 ms 4572 KB Output is correct
19 Runtime error 1 ms 604 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1 ms 604 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -