Submission #605009

#TimeUsernameProblemLanguageResultExecution timeMemory
605009gagik_2007Stations (IOI20_stations)C++17
0 / 100
3047 ms2097152 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>gic[1007]; int tin[1507], tout[1507]; int timer = 0; void dfs(int v, int par = -1) { tin[v] = timer++; for (int i = 0; i < g[v].size(); i++) { int to = g[v][i]; if (to != par) { dfs(to, v); } } tout[v] = timer; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<int> lbl(n); for (int i = 0; i < n - 1; i++) { g[v[i]].push_back(u[i]); g[u[i]].push_back(v[i]); } dfs(0); for (int i = 0; i < n; i++) { lbl[i] = tin[i] * 1000 + tout[i]; } return lbl; } bool papa(int v, int u) { int iv = v / 1000; int ov = v % 1000; int iu = u / 1000; int ou = u % 1000; return (iv <= iu && ov >= ou); } int find_next_station(int s, int t, vector<int> c) { if (c.size() == 1)return c[0]; int par = -1; for (auto x : c) { if (x / 1000 < s / 1000) { par = x; break; } } if (papa(s, t)) { for (auto x : c) { if (papa(x, t) && x != par) { return x; } } } else { return par; } } /* 1 8 1000 0 1 0 2 1 3 1 4 3 5 3 6 5 7 5 7 2 5 2 3 0 6 5 3 7 4 5 6 4 3 1 8 1000 0 1 0 2 1 3 1 4 3 5 3 6 5 7 5 7 2 5 2 3 0 6 5 3 7 4 5 6 4 3 1 8 1000000 0 1 0 2 1 3 1 4 2 5 2 6 3 7 5 7 2 3 1 7 3 2 5 5 0 5 2 5 0 2 */

Compilation message (stderr)

stations.cpp: In function 'void dfs(int, int)':
stations.cpp:36:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  for (int i = 0; i < g[v].size(); i++) {
      |                  ~~^~~~~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:85:1: warning: control reaches end of non-void function [-Wreturn-type]
   85 | }
      | ^
#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...