Submission #433381

#TimeUsernameProblemLanguageResultExecution timeMemory
433381Enkognit기지국 (IOI20_stations)C++14
0 / 100
5 ms912 KiB
#include <bits/stdc++.h> #include "stations.h" #include <vector> #define ll long long #define mp make_pair #define pb push_back #define fi first #define se second using namespace std; vector<int> c[1005]; vector<int> vv; ll T; void dfs(int h,int k, int p) { if (k%2==0) vv.pb(h); for (int i = 0; i < c[h].size(); i++) if (c[h][i]!=p) { dfs(c[h][i], k+1, h); } if (k%2) vv.pb(h); } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { vector<int> f; T=0; //vector<pair<ll, ll> > ed; for (int i = 0; i < u.size(); i++) { //ed.pb(mp(u[i], v[i])); c[u[i]].pb(v[i]); c[v[i]].pb(u[i]); } dfs(0, 0, 0); f.resize(n, 0); for (int i = 0; i < n; i++) f[vv[i]]=i; //for (int i = 0; i < n; i++) cout << vv[i] << "\n"; //for (int i = 0; i < ed.size(); i++) // cout << vv[ed[i].fi] << " " << vv[ed[i].se] << "\n"; //cout << "---\n"; for (int i = 0; i < n; i++) c[i].clear(); assert(f.size()==n); vv.clear(); return f; } int find_next_station(int s, int t, std::vector<int> c) { //for (int i = 0; i < c.size(); i++) // cout << c[i] << " "; //cout << "\n"; assert(c.size()==0); if (s<c[0]) { if (!(t>s && t<c[0])) return c[0]; ll lst=s; for (int i = 1; i < c.size(); i++) if (t>lst && c[i]>=t) return c[i]; else lst=c[i]; return c[0]; }else { if (!(t<s && t>c[0])) return c[0]; ll lst=s; for (int i = c.size()-1; i > -1; i--) if (t<lst && t>=c[i]) return c[i]; else lst=c[i]; } //assert(0); return 1; } /* 1 5 10 0 1 1 2 1 3 2 4 2 2 0 2 1 3 3 */

Compilation message (stderr)

stations.cpp: In function 'void dfs(int, int, int)':
stations.cpp:19:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int i = 0; i < c[h].size(); i++)
      |                     ~~^~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:36:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  for (int i = 0; i < u.size(); i++)
      |                  ~~^~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from stations.cpp:1:
stations.cpp:60:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |     assert(f.size()==n);
      |            ~~~~~~~~^~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:78:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |         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...