Submission #590547

#TimeUsernameProblemLanguageResultExecution timeMemory
590547fuad27Stations (IOI20_stations)C++17
0 / 100
2 ms404 KiB
#include "stations.h" #include <vector> #include<bits/stdc++.h> using namespace std; #define pb push_back const int N = 1010; typedef long long ll; vector<int> g[N]; vector<int> tin, tout, depth; int cnt=0; void dfs(int at, int p) { tin[at]=cnt++; for(int to:g[at]) { if(to != p){ depth[to]=depth[at]+1; dfs(to, at); } } tout[at]=cnt++; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { cnt=0; tin.clear(); tout.clear(); depth.clear(); tin.resize(n); tout.resize(n); depth.resize(n); for(int i = 0;i<n-1;i++) { g[u[i]].pb(v[i]); g[v[i]].pb(u[i]); } dfs(0, 0); depth[0]=0; vector<int> l(n); for(int i = 0;i<n;i++) { if(depth[i]%2==0) { l[i]=tin[i]/2; } else { l[i]=tout[i]/2; } cout<<tin[i]<< " " << tout[i] << " " << l[i] << "\n"; } for(int i = 0;i<=n;i++)g[i].clear(); return l; } int find_next_station(int s, int t, std::vector<int> c) { int k =0; bool parity=1; int tins=0; int touts=0; int mx = 0, mn = 1e9; for(int i = 0;i<c.size();i++) { mx=max(mx, c[i]); mn=min(mn, c[i]); } int mx2 = 0; for(int i = 0;i<c.size();i++) { if(mx==c[i])continue; mx2=max(mx2, c[i]); } if(mx > s) { parity=0; } if(!parity) { tins=2*s; touts=2*mx2+1; } else { touts=2*s; tins=2*mn+1; } cout<<s<<":" << tins<<" " <<touts<<"\n"; if(tins <= 2*t and 2*t <= touts) { for(int i = 0;i<c.size();i++) { if(!parity) { if(c[i] <= t) { return c[i]; } } else { if(c[i] >= t)return c[i]; } } } else { for(int i = 0;i<c.size();i++) { if(tins > 2*c[i] or 2*c[i] > touts)return c[i]; } } return 0; }

Compilation message (stderr)

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:52:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |  for(int i = 0;i<c.size();i++) {
      |                ~^~~~~~~~~
stations.cpp:57:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |  for(int i = 0;i<c.size();i++) {
      |                ~^~~~~~~~~
stations.cpp:74:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |   for(int i = 0;i<c.size();i++) {
      |                 ~^~~~~~~~~
stations.cpp:86:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   86 |   for(int i = 0;i<c.size();i++) {
      |                 ~^~~~~~~~~
stations.cpp:49:6: warning: unused variable 'k' [-Wunused-variable]
   49 |  int k =0;
      |      ^
#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...