# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
308650 | 2020-10-01T16:04:16 Z | nadorb | Stations (IOI20_stations) | C++14 | 3000 ms | 1541048 KB |
#include "stations.h" #include <bits/stdc++.h> using namespace std; vector<vector<int>>graf; vector<int>visit; vector<pair<int,int>>beki; void dfs(int v,int &ido){ visit[v]=1; beki[v].first=ido; ido++; for(int i:graf[v]){ if(!visit[i]){ dfs(i,ido); } } beki[v].second=ido; ido++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<int> labels(n),tav(n,-1); graf.clear(); //clear+resize=assign visit.clear(); beki.clear(); graf.resize(n); visit.resize(n,0); beki.resize(n); int ido=0; for (int i = 0; i < n-1; i++) { graf[u[i]].push_back(v[i]); graf[v[i]].push_back(u[i]); } dfs(0,ido); //bfs queue<int>q; q.push(0); tav[0]=0; while(!q.empty()){ int d=q.front(); q.pop(); for(int i:graf[d]){ if(tav[i]==-1){ tav[i]=(tav[d]+1)%2; } q.push(i); } } //bfs end for(int i=0;i<n;i++){ if(tav[i]==0){ labels[i]=(beki[i].first)/2; } else{ labels[i]=(beki[i].second)/2; } } return labels; } int find_next_station(int s, int t, vector<int> c) { int ki=c[0]; if(s<c[0]){ s=1000-s; t=1000-t; for(int i:c){ i=1000-i; } } sort(c.begin(),c.end()); if(c.size()!=1){ if(t<c[1] || t>s){ c[0]=0; } else{ for(int i=1;i<c.size();i++){ if(t<=c[i]){ ki=c[i]; break; } } } } return ki; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3122 ms | 1100988 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3148 ms | 1541048 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3063 ms | 288 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3041 ms | 256 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3112 ms | 747104 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |