# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1039556 | 2024-07-31T04:29:26 Z | 정지훈(#11027) | Petrol stations (CEOI24_stations) | C++17 | 24 ms | 6960 KB |
#include <bits/stdc++.h> using namespace std; vector<int> adj[100005]; int ind[100005]; int main(void){ int n,k; scanf("%d %d",&n,&k); for(int i=1;i<n;i++) { int u,v,w; scanf("%d %d %d",&u,&v,&w); adj[u].push_back(v); adj[v].push_back(u); } int x; for(int i=0;i<n;i++) { if (adj[i].size()==1) { x=i; break; } } int pr=-1; ind[x]=0; for(int i=1;i<n;i++){ for(int j=0;j<adj[x].size();j++){ if (pr!=adj[x][j]) { pr=x; x=adj[x][j]; break; } } ind[x]=i; } for(int i=0;i<n;i++){ int now=ind[i]; long long ret=0; ret+=1LL*(now/k)*(n-now-1); ret+=1LL*((n-now-1)/k)*now; printf("%lld\n",ret); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2904 KB | Output is correct |
2 | Incorrect | 1 ms | 2904 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2904 KB | Output is correct |
2 | Incorrect | 1 ms | 2904 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2904 KB | Output is correct |
2 | Correct | 24 ms | 6960 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2904 KB | Output is correct |
2 | Incorrect | 1 ms | 2904 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2904 KB | Output is correct |
2 | Incorrect | 1 ms | 2904 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2904 KB | Output is correct |
2 | Incorrect | 1 ms | 2904 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2904 KB | Output is correct |
2 | Incorrect | 1 ms | 2904 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |