# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
749525 | 2023-05-28T07:06:44 Z | 반딧불(#9967) | Grapevine (NOI22_grapevine) | C++17 | 3000 ms | 20424 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, q; int arr[100002]; vector<pair<int, int> > link[100002]; ll len[100002]; ll dfs(int x, int p=-1){ if(arr[x]) return 0; ll ret = 1e18; for(auto y: link[x]){ if(y.first == p) continue; ret = min(ret, len[y.second] + dfs(y.first, x)); } return ret; } int main(){ map<pair<int, int>, int> mp; scanf("%d %d", &n, &q); for(int i=1; i<n; i++){ int a, b; scanf("%d %d %lld", &a, &b, &len[i]); link[a].push_back(make_pair(b, i)); link[b].push_back(make_pair(a, i)); mp[make_pair(a, b)] = mp[make_pair(b, a)] = i; } while(q--){ int t; scanf("%d", &t); if(t==1){ int x; scanf("%d", &x); ll tmp = dfs(x); if(tmp > 1e17) tmp = -1; printf("%lld\n", tmp); } else if(t==2){ int x; scanf("%d", &x); arr[x] = !arr[x]; } else{ int a, b; ll c; scanf("%d %d %lld", &a, &b, &c); len[mp[make_pair(a, b)]] = c; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 3020 KB | Output is correct |
2 | Correct | 11 ms | 3028 KB | Output is correct |
3 | Correct | 6 ms | 3028 KB | Output is correct |
4 | Correct | 7 ms | 3028 KB | Output is correct |
5 | Correct | 6 ms | 3028 KB | Output is correct |
6 | Correct | 4 ms | 3056 KB | Output is correct |
7 | Correct | 10 ms | 3028 KB | Output is correct |
8 | Correct | 10 ms | 3028 KB | Output is correct |
9 | Correct | 10 ms | 3072 KB | Output is correct |
10 | Correct | 17 ms | 3084 KB | Output is correct |
11 | Correct | 18 ms | 3056 KB | Output is correct |
12 | Correct | 15 ms | 3060 KB | Output is correct |
13 | Correct | 11 ms | 3072 KB | Output is correct |
14 | Correct | 11 ms | 3060 KB | Output is correct |
15 | Correct | 10 ms | 3028 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3062 ms | 20024 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3051 ms | 20424 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3046 ms | 19792 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3053 ms | 19636 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 3020 KB | Output is correct |
2 | Correct | 11 ms | 3028 KB | Output is correct |
3 | Correct | 6 ms | 3028 KB | Output is correct |
4 | Correct | 7 ms | 3028 KB | Output is correct |
5 | Correct | 6 ms | 3028 KB | Output is correct |
6 | Correct | 4 ms | 3056 KB | Output is correct |
7 | Correct | 10 ms | 3028 KB | Output is correct |
8 | Correct | 10 ms | 3028 KB | Output is correct |
9 | Correct | 10 ms | 3072 KB | Output is correct |
10 | Correct | 17 ms | 3084 KB | Output is correct |
11 | Correct | 18 ms | 3056 KB | Output is correct |
12 | Correct | 15 ms | 3060 KB | Output is correct |
13 | Correct | 11 ms | 3072 KB | Output is correct |
14 | Correct | 11 ms | 3060 KB | Output is correct |
15 | Correct | 10 ms | 3028 KB | Output is correct |
16 | Execution timed out | 3062 ms | 20024 KB | Time limit exceeded |
17 | Halted | 0 ms | 0 KB | - |