Submission #872177

#TimeUsernameProblemLanguageResultExecution timeMemory
872177kitkat12Stations (IOI20_stations)C++14
0 / 100
3 ms588 KiB
#include <bits/stdc++.h> #include <typeinfo> using namespace std; typedef long long ll; #define mp make_pair #define pb push_back #define F first #define S second #define debug(x) std::cout << #x << ": " << x << "\n" //#define all(v) v.begin(), v.end() #define LPRINT(a, b) for (auto&(a) : (b)) #define li(i,a,b) for (int (i) = (a); (i) < (b); (i)++) #define lij(i,a,b) for (int (i) = (a); (i) <= (b); (i)++) #define endl '\n' #define mem(name,val) memset(name,val,sizeof(name)) //#define mod 1000000007 #define mod 998244353 vector<int> adj[1001]; bool visited[1001]; int timer = 0; int m = 1000; void dfs(int start, vector<int>& labels){ visited[start] = 1; labels[start] = timer++; for(int neigh : adj[start]){ if(!visited[neigh]){ dfs(neigh, labels); } } labels[start] = m * labels[start] + timer++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<int> labels(n); for(int i = 0; i<u.size(); i++){ adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } timer = 0; //dfs for(int i = 0; i<n; i++){ if(!visited[u[i]]){ dfs(u[i], labels); } } return labels; } int find_next_station(int s, int t, vector<int> c) { int sd = s/m, sf = s%m; int td = t/m, tf = t%m; int ms = min(sd, td); int mf = max(sf,tf); for(int i = 0; i<c.size(); i++){ int cd = c[i]/m, cf = c[i]%m; if( cd>=ms && cd<=(sd+tf-ms) && cf <= mf && cf >= (sf + tf-mf) ){ return c[i]; } } return c[0]; }

Compilation message (stderr)

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:43:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |  for(int i = 0; i<u.size(); i++){
      |                 ~^~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:67:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |  for(int i = 0; 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...