Submission #872187

#TimeUsernameProblemLanguageResultExecution timeMemory
872187kitkat12Stations (IOI20_stations)C++14
0 / 100
529 ms936 KiB
#include <bits/stdc++.h> #include "stations.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; int dtime[1001], ftime[1001]; void dfs(int start){ visited[start] = 1; dtime[start] = timer++; for(int neigh : adj[start]){ if(!visited[neigh]){ dfs(neigh); } } ftime[start] = timer++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<int> labels(n,0); memset(visited,false,sizeof(visited)); for(int i=0;i<n;i++) adj[i].clear(); 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(0); for(int i = 0; i<n; i++){ labels[i] = m * dtime[i] + ftime[i]; } 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); if(sd >= td && sf <= tf){ for(int i = 0; i<c.size(); i++){ int cd = c[i]/m, cf = c[i]%m; if( cd>=ms && cd<=(sd+td-ms) && cf <= mf && cf >= (sf + tf-mf) ){ return c[i]; } } } return c[0]; } // int main() // { // ios_base::sync_with_stdio(false); cin.tie(NULL); // return 0; // }

Compilation message (stderr)

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