# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
935035 | 2024-02-28T12:48:33 Z | anton | 꿈 (IOI13_dreaming) | C++17 | 24 ms | 12100 KB |
#include "dreaming.h" #include<bits/stdc++.h> using namespace std; #define int long long #define pii pair<int, int> struct Tree{ vector<vector<pii>> adj; vector<int> longest; int min_len = 1e9; }; vector<vector<pii>> adj; vector<bool> vis; vector<Tree> forest; Tree sTree; void get_tree(int id, int anc){ //cout<<id<<endl; vis[id] = true; int tree_id = sTree.adj.size(); sTree.adj.push_back(vector<pii>(0)); for(auto e: adj[id]){ if(e.first!=anc){ int future_id = sTree.adj.size(); get_tree(e.first, id); sTree.adj[tree_id].push_back(pii(future_id, e.second)); sTree.adj[future_id].push_back(pii(tree_id, e.second)); } } //cout<<id<<" done "<<endl; } int get_len(int id, int anc, Tree& tr){ int ans = 0; for(auto e: tr.adj[id]){ if(e.first!=anc){ ans = max(ans, get_len(e.first, id, tr)+1); } } return ans; } signed travelTime(signed N,signed M, signed L,signed A[], signed B[], signed T[]) { adj.resize(N); vis.resize(N); for(int i =0; i<M; i++){ adj[A[i]-1].push_back(pii(B[i]-1, T[i])); adj[B[i]-1].push_back(pii(A[i]-1, T[i])); } for(int i = 0; i<N; i++){ if(!vis[i]){ //cerr<<i<<endl; sTree.adj.clear(); get_tree(i, -1); forest.push_back(sTree); } } for(int j = 0; j<forest.size(); j++){ forest[j].longest.resize(forest[j].adj.size()); for(int i = 0; i<forest[j].adj.size(); i++){ forest[j].longest[i] = get_len(i, -1, forest[j]); forest[j].min_len= min(forest[j].min_len, forest[j].longest[i]); } } return forest[0].min_len + forest[1].min_len + L; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 24 ms | 12100 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 344 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 24 ms | 12100 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 14 ms | 9564 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 344 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 24 ms | 12100 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |