Submission #420001

#TimeUsernameProblemLanguageResultExecution timeMemory
420001NintsiChkhaidzeStations (IOI20_stations)C++14
10 / 100
991 ms600 KiB
#include "stations.h" #include <bits/stdc++.h> #define pb push_back using namespace std; vector <int> vec[1005]; int cnt = -1,in[1005],out[1005]; bool q=0; void dfs(int x,int p){ in[x] = ++cnt; for (int j=0;j<vec[x].size();j++){ int to = vec[x][j]; if (to == p) continue; dfs(to,x); } out[x] = cnt; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<int> labels; for (int i=0;i<1001;i++){ vec[i].clear(); in[i] = out[i] = 0; } for (int i=0;i<u.size();i++){ vec[u[i]].pb(v[i]); vec[v[i]].pb(u[i]); } cnt=0; dfs(0,0); for (int i=0;i<n;i++) labels.pb(in[i]*1000 + out[i]); return labels; } int find_next_station(int s, int t, vector<int> c) { int Ins = (s/1000),Int = (t/1000),Out = (t%1000); if (Ins < Int){ for (int i=1;i<c.size();i++) if (Int >= (c[i]/1000) && (c[i]%1000) >= Out) return c[i]; } return c[0]; }

Compilation message (stderr)

stations.cpp: In function 'void dfs(int, int)':
stations.cpp:10:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for (int j=0;j<vec[x].size();j++){
      |                  ~^~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:24:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for (int i=0;i<u.size();i++){
      |                  ~^~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:39:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for (int i=1;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...