Submission #1040345

#TimeUsernameProblemLanguageResultExecution timeMemory
1040345HD1Stations (IOI20_stations)C++14
0 / 100
3006 ms2097156 KiB
#include "stations.h" #include<bits/stdc++.h> #define ss second #define all(s) s.begin(),s.end() #define sz(s) ll(s.size()) #define pb push_back typedef long long ll; const ll MAX=1e6; using namespace std; ll marc=1; vector<ll> gfo[MAX]; ll m[MAX]; void dfs(int u, int f){ m[u]=marc; for(auto v:gfo[u]){ if(v!=f){ marc++; dfs(v,u); } } } vector<int> label(int n, int k, vector<int> u, vector<int> v){ vector<int> labels(n); for(int i=0; i<sz(u); i++){ gfo[u[i]].pb(v[i]); gfo[v[i]].pb(u[i]); } for(int i=0; i<n; i++){ if(sz(gfo[i])==1 && labels[i]==0){ dfs(i, i); } // cout<<i<<'\n'; // for(auto v:gfo[i]){ // cout<<v<<' '; // } // cout<<'\n'; } for(int i=0; i<n; i++){ labels[i]=m[i]; } return labels; } int find_next_station(int s, int t, vector<int> c){ sort(all(c)); if(s>t){ return c[0]; } return c[sz(c)-1]; }
#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...