답안 #959582

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
959582 2024-04-08T13:17:13 Z TAhmed33 Passport (JOI23_passport) C++
16 / 100
2000 ms 201188 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e3 + 25;
const int inf = MAXN << 4;
int n, q;
pair <int, int> a[MAXN];
vector <pair <int, int>> adj[MAXN];
int dist[MAXN][MAXN];
int main () {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 1; i <= 2 * n; i++) {
        for (int j = 1; j <= 2 * n; j++) {
            dist[i][j] = inf;
        }
        dist[i][i] = 0;
    }
    for (int i = 1; i <= n; i++) {
        cin >> a[i].first >> a[i].second;
        for (int j = a[i].first; j <= a[i].second; j++) {
            adj[i + n].push_back({j, 0});
            dist[i + n][j] = 0;
        }
    }
    for (int i = 1; i <= n; i++) {
        adj[i].push_back({i + n, 1});
        dist[i][i + n] = 1;
    }
    for (int k = 1; k <= 2 * n; k++) {
        for (int i = 1; i <= 2 * n; i++) {
            for (int j = 1; j <= 2 * n; j++) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    cin >> q;
    while (q--) {
        int x; cin >> x;
        int mn = inf;
        for (int i = 1; i <= 2 * n; i++) {
            mn = min(mn, dist[x][i] + dist[i][1] + dist[i][n]);
        }
        cout << (mn == inf ? -1 : mn) << '\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Runtime error 762 ms 201188 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 356 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 584 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 1 ms 584 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 185 ms 4388 KB Output is correct
12 Correct 197 ms 4188 KB Output is correct
13 Correct 201 ms 4956 KB Output is correct
14 Correct 177 ms 4660 KB Output is correct
15 Correct 193 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 356 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 584 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 1 ms 584 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 185 ms 4388 KB Output is correct
12 Correct 197 ms 4188 KB Output is correct
13 Correct 201 ms 4956 KB Output is correct
14 Correct 177 ms 4660 KB Output is correct
15 Correct 193 ms 4444 KB Output is correct
16 Execution timed out 2066 ms 106068 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 356 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 584 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 1 ms 584 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 185 ms 4388 KB Output is correct
12 Correct 197 ms 4188 KB Output is correct
13 Correct 201 ms 4956 KB Output is correct
14 Correct 177 ms 4660 KB Output is correct
15 Correct 193 ms 4444 KB Output is correct
16 Execution timed out 2066 ms 106068 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Runtime error 762 ms 201188 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -