Submission #1060571

#TimeUsernameProblemLanguageResultExecution timeMemory
1060571MihailoStations (IOI20_stations)C++17
100 / 100
636 ms1196 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define xx first #define yy second #define pll pair<long long, long long> #define MOD 1000000007 typedef long long ll; using namespace std; mt19937 mt(time(nullptr)); /* static int max_label = 0; static int r, n, k, q; static std::vector<int> u, v, labels, answers; static std::map<int, int> reverse_labels; static std::vector<std::vector<int>> adjlist; static int s, t, w; static std::vector<int> c; */ vector<int> adj[2000]; bool d[2000]; ll mm, m[2000]; void mark(ll node) { m[node]=mm; mm++; } void dfsd(ll node, ll prev) { d[node]=!d[prev]; for(int i=0; i<adj[node].size(); i++) { if(adj[node][i]!=prev) dfsd(adj[node][i], node); } } void euler(ll node, ll prev) { if(d[node]) mark(node); for(int i=0; i<adj[node].size(); i++) { if(adj[node][i]!=prev) euler(adj[node][i], node); } if(!d[node]) mark(node); } vector<int> label(int n, int k, vector<int> u, vector<int> v) { for(int i=0; i<n; i++) adj[i].clear(); for(int i=0; i<n; i++) d[i]=0; for(int i=0; i<n; i++) m[i]=0; mm=0; for(int i=0; i<n-1; i++) { adj[u[i]].pb(v[i]); adj[v[i]].pb(u[i]); } dfsd(0, 0); euler(0, 0); vector<int> rez; for(int i=0; i<n; i++) rez.pb(m[i]); return rez; } int find_next_station(int s, int t, vector<int> c) { if(c[0]>s) { if(t<s||t>=c[c.size()-1]) { return c[c.size()-1]; } for(int i=0; i<c.size(); i++) { if(t<=c[i]) return c[i]; } } else { if(t>s||t<=c[0]) { return c[0]; } for(int i=c.size()-1; i>=0; i--) { if(t>=c[i]) return c[i]; } } }

Compilation message (stderr)

stations.cpp: In function 'void dfsd(ll, ll)':
stations.cpp:31:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for(int i=0; i<adj[node].size(); i++) {
      |               ~^~~~~~~~~~~~~~~~~
stations.cpp: In function 'void euler(ll, ll)':
stations.cpp:38:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |  for(int i=0; i<adj[node].size(); i++) {
      |               ~^~~~~~~~~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:65:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |   for(int i=0; i<c.size(); i++) {
      |                ~^~~~~~~~~
stations.cpp:77:1: warning: control reaches end of non-void function [-Wreturn-type]
   77 | }
      | ^
#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...