Submission #364783

#TimeUsernameProblemLanguageResultExecution timeMemory
364783leinad2Stations (IOI20_stations)C++17
0 / 100
3080 ms864 KiB
#include "stations.h" #include<bits/stdc++.h> using namespace std; vector<int>adj[1010]; int in[1010], out[1010], cnt, vis[1010]; void dfs(int v) { in[v]=++cnt; for(int i=0;i<adj[v].size();i++) { int p=adj[v][i]; if(!vis[p]) { vis[p]=1; dfs(p); } } out[v]=cnt; } vector<int>label(int n, int k, vector<int>u, vector<int>v) { vis[0]=1; for(int i=0;i<u.size();i++) { adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } dfs(0); for(int i=0;i<n;i++)if(!vis[i])for(;;); vector<int>ans; for(int i=0;i<n;i++)ans.push_back(in[i]*1000+out[i]-1001); return ans; } int find_next_station(int s, int t, vector<int>c) { int aa=s/1000; int bb=s%1000; int cc=t/1000; int dd=t%1000; if(cc<=aa&&bb<=dd||bb<cc||dd<aa) { for(int i=0;i<c.size();i++) { int ee=c[i]/1000; int ff=c[i]%1000; if(ee<=aa&&bb<=ff)return c[i]; } } for(int i=0;i<c.size();i++) { int ee=c[i]/1000; int ff=c[i]%1000; if(ee<=cc&&dd<=ff&&!(ee<=aa&&bb<=ff))return c[i]; } }

Compilation message (stderr)

stations.cpp: In function 'void dfs(int)':
stations.cpp:9:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i=0;i<adj[v].size();i++)
      |                 ~^~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:23:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for(int i=0;i<u.size();i++)
      |              ~^~~~~~~~~
stations.cpp:29:34: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   29 |   for(int i=0;i<n;i++)if(!vis[i])for(;;);
      |                                  ^~~
stations.cpp:30:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   30 |     vector<int>ans;
      |     ^~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:40:14: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   40 |     if(cc<=aa&&bb<=dd||bb<cc||dd<aa)
      |        ~~~~~~^~~~~~~~
stations.cpp:42:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         for(int i=0;i<c.size();i++)
      |                     ~^~~~~~~~~
stations.cpp:49:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     for(int i=0;i<c.size();i++)
      |                 ~^~~~~~~~~
stations.cpp:55:1: warning: control reaches end of non-void function [-Wreturn-type]
   55 | }
      | ^
#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...