# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
672631 | tbzard | Stations (IOI20_stations) | C++14 | 131 ms | 40176 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
vector<int> g[1002];
int best[12][1002][1002];
int comp[10002];
int node[10002];
int color[12][1002];
int b = 0, idx = 0;
vector<int> label(int n, int k, vector<int> u, vector<int> v){
memset(best[idx], -1, sizeof(best[idx]));
vector<int> ans(n);
for(int i=0;i<n;i++){
ans[i] = b;
comp[b] = idx;
node[b] = i;
color[idx][i] = b;
b++;
}
for(int i=0;i<n;i++){
g[i].clear();
}
for(int i=0;i<u.size();i++){
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
for(int i=0;i<n;i++){
queue<int> q;
q.push(i);
best[idx][i][i] = 0;
while(!q.empty()){
int u = q.front();
q.pop();
for(int j=0;j<g[u].size();j++){
int v = g[u][j];
if(best[idx][i][v] == -1){
best[idx][i][v] = best[idx][i][u] + 1;
q.push(v);
}
}
}
}
idx++;
return ans;
}
int find_next_station(int s, int t, vector<int> c){
int idx = comp[s];
s = node[s], t = node[t];
for(int i=0;i<c.size();i++){
int v = node[c[i]];
if(best[idx][s][t]-1 == best[idx][s][v]) return c[i];
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |