Submission #1292740

#TimeUsernameProblemLanguageResultExecution timeMemory
1292740ChuanChenStations (IOI20_stations)C++20
10 / 100
388 ms564 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 1e4+3; vector<int> adj[MAXN]; int tin[MAXN], tout[MAXN], tempo; bool used[MAXN]; void dfs(int no){ used[no] = true; tin[no] = tempo++; for(int v : adj[no]) if(!used[v]){ dfs(v); } tout[no] = tempo; } inline int pre(int a); inline int pos(int a); vector<int> label(int n, int k, vector<int> u, vector<int> v){ for(int i = 0; i < n; i++){ used[i] = false; tin[i] = tout[i] = 0; adj[i].clear(); } tempo = 0; for (int i = 0; i < (int)u.size(); i++){ adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } dfs(0); vector<int> labels(n); for (int i = 0; i < n; i++) { // labels[i] = 0; labels[i] = tin[i]*1000+tout[i]; // cerr << "i: " << i << " " << pre(labels[i]) << ' ' << pos(labels[i]) << endl; } return labels; } inline int pre(int a){ return a/1000; } inline int pos(int a){ return a%1000; } int find_next_station(int s, int t, vector<int> c) { if(pre(s) <= pre(t) && pos(t) <= pos(s)){ //t eh filho for(int l : c){ if(pre(l) <= pre(s) && pos(s) <= pos(l)) continue; if(pre(l) <= pre(t) && pos(t) <= pos(l)) return l; } } for(int l : c){ if(pre(l) <= pre(s) && pos(s) <= pos(l)) return l; } // return c[0]; }

Compilation message (stderr)

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:65:1: warning: control reaches end of non-void function [-Wreturn-type]
   65 | }
      | ^
#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...