답안 #926353

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
926353 2024-02-12T20:28:34 Z OAleksa Passport (JOI23_passport) C++14
0 / 100
530 ms 1048576 KB
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define int long long
const int N = 2e5 + 69;
int n, l[N], r[N], q, p[N];
vector<int> g[N];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tt = 1;
  //cin >> tt;
  while (tt--) {
  	cin >> n;
  	for (int i = 1;i <= n;i++) {
  		cin >> l[i] >> r[i];
  		for (int j = l[i];j <= r[i];j++) {
  			g[i].push_back(j);
  		}
  	}
  	cin >> q;
  	for (int i = 1;i <= q;i++) {
  		int x;
  		cin >> x;
  		queue<int> q;
  		q.push(x);
  		vector<int> dis(n + 1, 1e9);
  		dis[x] = 0;
  		while (!q.empty()) {
  			auto v = q.front();
  			q.pop();
  			for (auto u : g[v]) {
  				if (dis[u] <= dis[v] + 1)
  					continue;
  				dis[u] = dis[v] + 1;
  				q.push(u);
  			}
  		}
  		int ans = -1;
  		for (int i = 1;i <= n;i++)
  			ans = max(ans, dis[i]);
  		if (ans == 1e9)
  			ans = -1;
  		cout << ans << '\n';
  	}
  }
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Correct 2 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Runtime error 530 ms 1048576 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Incorrect 2 ms 8792 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Incorrect 2 ms 8792 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Correct 1 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Correct 1 ms 8796 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 8796 KB Output is correct
7 Incorrect 2 ms 8792 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Correct 2 ms 8796 KB Output is correct
3 Correct 1 ms 8796 KB Output is correct
4 Runtime error 530 ms 1048576 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -