Submission #308621

#TimeUsernameProblemLanguageResultExecution timeMemory
308621lordlorincStations (IOI20_stations)C++17
31.04 / 100
1190 ms1268 KiB
#include "stations.h" #include <vector> using namespace std; vector<vector<int> > sor; vector<bool> volt; vector<int> eleres, tavozas; int time = -1; void bejaras (int hely){ time++; eleres[hely] = time; volt[hely] = true; for (int x : sor[hely]){ if (volt[x] == false){ bejaras(x); } } time++; tavozas[hely] = time; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { sor.assign(n, vector<int>(0)); volt.assign(n, false); eleres.assign(n, 0); tavozas.assign(n, 0); time = -1; for (int i = 0; i < u.size(); i++){ sor[u[i]].push_back(v[i]); sor[v[i]].push_back(u[i]); } bejaras(0); vector<int> labels(n); for (int i = 0; i < n; i++) labels[i] = eleres[i] * 2000 + tavozas[i]; return labels; } int find_next_station(int s, int t, std::vector<int> c) { pair<int, int> hely, cel; hely.first = s / 2000; hely.second = s % 2000; cel.first = t / 2000; cel.second = t % 2000; vector<pair<int, int> > szomszedok(c.size()); for (int i = 0; i < c.size(); i++){ szomszedok[i].first = c[i] / 2000; szomszedok[i].second = c[i] % 2000; } int szuloindex = -1; for (int i = 0; i < c.size(); i++) { if (szomszedok[i].first < hely.first) szuloindex = i; } for (int i = 0; i < c.size(); i++){ if (i != szuloindex){ if (szomszedok[i].first <= cel.first && szomszedok[i].second >= cel.second){ return c[i]; } } } return c[szuloindex]; }

Compilation message (stderr)

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:31:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for (int i = 0; i < u.size(); i++){
      |                  ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:55:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for (int i = 0; i < c.size(); i++){
      |                     ~~^~~~~~~~~~
stations.cpp:61:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for (int i = 0; i < c.size(); i++) {
      |                     ~~^~~~~~~~~~
stations.cpp:65:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     for (int i = 0; i < c.size(); i++){
      |                     ~~^~~~~~~~~~
#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...