Submission #1095427

#TimeUsernameProblemLanguageResultExecution timeMemory
1095427dostsStations (IOI20_stations)C++17
0 / 100
3037 ms2097152 KiB
//Dost SEFEROĞLU #include <bits/stdc++.h> #include "stations.h" #pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt") using namespace std; //#define int long long #define pii pair<int,int> #define ff first #define ss second #define sp << " " << #define all(cont) cont.begin(),cont.end() #define vi vector<int> const int N = 1000; vi edges[N]; vi ls(N),tin(N),tout(N); int timer = 1; void dfs(int node,int p,int deppy = 0) { tin[node] = timer++; for (auto it : edges[node]) if (it != p) dfs(it,node,deppy^1); tout[node] = timer++; if (deppy) ls[node] = tout[node]; else ls[node] = tin[node]; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { vi labels(n); for (int i=0;i<n-1;i++) { edges[u[i]].push_back(v[i]); edges[v[i]].push_back(u[i]); } dfs(0,0); for (int i=0;i<n;i++) labels[i] = ls[i]; return labels; } int find_next_station(int s, int t, std::vector<int> c) { bool ins = 0; if (c[0] > s) ins = 1; if (ins) { //tin bu int mx = 0; //mx parentim sort(all(c)); if (s != 1) mx = c.back(); int prv = s; for (auto it : c) { if (it == mx) return it; int onuntini = prv+1; prv = it; if (onuntini <= t && it >= t) return it; } return -1; } else { //tout bu sort(all(c),greater<int>()); int mn = c.back(); int prv = s+1; for (auto it : c) { if (it == mn) return it; int onuntoutu = prv-1; prv = it; if (onuntoutu >= t && it <= t) return it; } return -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...