Submission #807200

#TimeUsernameProblemLanguageResultExecution timeMemory
807200AndreyStations (IOI20_stations)C++14
0 / 100
736 ms932 KiB
#include "stations.h" #include<bits/stdc++.h> using namespace std; vector<int> yay(0); vector<int> haha[10001]; vector<int> st(10001); void dfs(int a, int t) { st[a] = 1; for(int i = 0; i < haha[a].size(); i++) { if(haha[a][i] != t) { dfs(haha[a][i],a); st[a]+=st[haha[a][i]]; } } } void dude(int a, int t, int d, int l, int r) { if(d%2) { yay[a] = r+1000; r--; } else { yay[a] = l; l++; } for(int i = 0; i < haha[a].size(); i++) { if(haha[a][i] != t) { dude(haha[a][i],a,d+1,l,l+st[haha[a][i]]-1); l+=haha[a][i]; } } } vector<int> label(int n, int k, vector<int> u, vector<int> v) { for(int i = 0; i < n; i++) { haha[i].clear(); } for(int i = 0; i < n-1; i++) { haha[u[i]].push_back(v[i]); haha[v[i]].push_back(u[i]); } yay.clear(); for(int i = 0; i < n; i++) { yay.push_back(0); } vector<int> ans(0); dfs(0,-1); dude(0,-1,0,0,n-1); for(int i = 0; i < n; i++) { ans.push_back(yay[i]); } return ans; } int find_next_station(int s, int t, vector<int> c) { if(c.size() == 1) { return c[0]; } t%=1000; for(int i = 0; i < c.size(); i++) { c[i]%=1000; } sort(c.begin(),c.end()); if(s >= 1000) { s%=1000; if(t > s) { return c[0]; } if(t < c[1]) { return c[0]; } for(int i = 1; i < c.size(); i++) { if(t >= c[i] && (t == c.size()-1 || t < c[i+1])) { return c[i]; } } } else { if(s == 0) { for(int i = 0; i < c.size(); i++) { if(c[i] >= t) { return c[i]; } } } else { if(t < s) { return c[c.size()-1]+1000; } if(t > c[c.size()-1]) { return c[c.size()-1]+1000; } for(int i = 0; i < c.size()-1; i++) { if(c[i] >= t) { return c[i]+1000; } } } } }

Compilation message (stderr)

stations.cpp: In function 'void dfs(int, int)':
stations.cpp:11:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int i = 0; i < haha[a].size(); i++) {
      |                    ~~^~~~~~~~~~~~~~~~
stations.cpp: In function 'void dude(int, int, int, int, int)':
stations.cpp:28:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i = 0; i < haha[a].size(); i++) {
      |                    ~~^~~~~~~~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:62:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |     for(int i = 0; i < c.size(); i++) {
      |                    ~~^~~~~~~~~~
stations.cpp:74:26: 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 = 1; i < c.size(); i++) {
      |                        ~~^~~~~~~~~~
stations.cpp:75:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |             if(t >= c[i] && (t == c.size()-1 || t < c[i+1])) {
      |                              ~~^~~~~~~~~~~~~
stations.cpp:82:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   82 |             for(int i = 0; i < c.size(); i++) {
      |                            ~~^~~~~~~~~~
stations.cpp:95:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   95 |             for(int i = 0; i < c.size()-1; i++) {
      |                            ~~^~~~~~~~~~~~
stations.cpp:102:1: warning: control reaches end of non-void function [-Wreturn-type]
  102 | }
      | ^
#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...