Submission #604586

#TimeUsernameProblemLanguageResultExecution timeMemory
604586gagik_2007Stations (IOI20_stations)C++17
5 / 100
923 ms612 KiB
#include "stations.h" #include <iostream> #include <algorithm> #include <string> #include <vector> #include <cmath> #include <ctime> #include <set> #include <map> #include <stack> #include <queue> #include <deque> #include <limits> #include <iomanip> #include <unordered_set> #include <unordered_map> #include <random> using namespace std; typedef long long ll; typedef long double ld; typedef ll itn; #define ff first #define ss second ll n; ll cnt[1007]; vector<int>g[1007]; vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<int> lbl(n); int cur = 0; for (int i = 0; i < n - 1; i++) { cnt[v[i]]++; cnt[u[i]]++; g[v[i]].push_back(u[i]); g[u[i]].push_back(v[i]); } int tser = -1; for (int i = 0; i < n; i++) { if (cnt[i] == 1) { tser = i; break; } } if (tser == -1)return lbl; lbl[tser] = 0; cur++; int lst = tser; tser = g[tser][0]; while (cnt[tser] != 1) { lbl[tser] = cur++; if (g[tser][0] == lst) { lst = tser; tser = g[tser][1]; } else { lst = tser; tser = g[tser][0]; } } lbl[tser] = cur; for (int i = 0; i < n; i++) { g[i].clear(); cnt[i] = 0; } return lbl; } int find_next_station(int s, int t, vector<int> c) { if (c.size() == 1)return c[0]; if (t > s)return max(c[0], c[1]); else return min(c[0], c[1]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...