# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
714728 | 2023-03-25T08:32:20 Z | Iliya | Toll (BOI17_toll) | C++17 | 3000 ms | 6144 KB |
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N = 5e4 + 10; const int Inf = 0x3f3f3f3f; vector<pair<int, int>> Adj[N], Order; int n, m, k, o, C[N], D[N], mark[N]; void DFS(int v, int comp) { mark[v] = true; C[v] = comp; for (auto [u, w] : Adj[v]) D[u] = D[v] + w, DFS(u, comp); } signed main() { scanf("%d%d%d%d", &k, &n, &m, &o); for (int i = 0; i < m; i++) { int a, b, t; scanf("%d%d%d", &a, &b, &t); Adj[a].emplace_back(b, t); } for (int i = 0; i < o; i++) { int a, b; scanf("%d%d", &a, &b); Order.emplace_back(a, b); } for (int i = 0; i < n; i++) if (!mark[i]) DFS(i, i); for (auto [u, v] : Order) { if (u < v) swap(u, v); if (C[u] == C[v]) printf("%d\n", D[u] - D[v]); else printf("%d\n", -1); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 6144 KB | Output is correct |
2 | Correct | 1 ms | 1364 KB | Output is correct |
3 | Correct | 2 ms | 1488 KB | Output is correct |
4 | Correct | 1 ms | 1488 KB | Output is correct |
5 | Correct | 2 ms | 1492 KB | Output is correct |
6 | Correct | 2 ms | 1524 KB | Output is correct |
7 | Correct | 2 ms | 1656 KB | Output is correct |
8 | Correct | 22 ms | 4308 KB | Output is correct |
9 | Correct | 22 ms | 4040 KB | Output is correct |
10 | Correct | 5 ms | 2140 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3067 ms | 4052 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1492 KB | Output is correct |
2 | Incorrect | 1 ms | 1364 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1492 KB | Output is correct |
2 | Incorrect | 1 ms | 1364 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 6144 KB | Output is correct |
2 | Correct | 1 ms | 1364 KB | Output is correct |
3 | Correct | 2 ms | 1488 KB | Output is correct |
4 | Correct | 1 ms | 1488 KB | Output is correct |
5 | Correct | 2 ms | 1492 KB | Output is correct |
6 | Correct | 2 ms | 1524 KB | Output is correct |
7 | Correct | 2 ms | 1656 KB | Output is correct |
8 | Correct | 22 ms | 4308 KB | Output is correct |
9 | Correct | 22 ms | 4040 KB | Output is correct |
10 | Correct | 5 ms | 2140 KB | Output is correct |
11 | Execution timed out | 3067 ms | 4052 KB | Time limit exceeded |
12 | Halted | 0 ms | 0 KB | - |