# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
305319 | Fdg | Stations (IOI20_stations) | C++14 | 1117 ms | 1136 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 <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <memory.h>
using namespace std;
vector<int> g[1002];
vector<int> color;
bool used[1002];
int ptr;
void dfs(int v, bool markFirst) {
used[v] = true;
if (markFirst) color[v] = ptr++;
for (int x : g[v])
if (!used[x]) dfs(x, !markFirst);
if (!markFirst) color[v] = ptr++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
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]);
}
ptr = 0;
color.resize(n, -1);
memset(used, false, sizeof(used));
dfs(0, true);
return color;
}
int find_next_station(int s, int t, vector<int> st) {
sort(st.begin(), st.end());
if (s < st[0]) {
if (t < s) return st.back();
for (int x : st)
if (t <= x) return x;
return st.back();
} else {
if (t > s) return st[0];
for (int i = st.size() - 1; i >= 0; --i)
if (st[i] <= t) return st[i];
return st[0];
}
}
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... |