제출 #658369

#제출 시각아이디문제언어결과실행 시간메모리
658369jiahng기지국 (IOI20_stations)C++14
100 / 100
881 ms10144 KiB
//#include "stations.h" #include <vector> #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pi; typedef vector <int> vi; typedef vector <pi> vpi; typedef pair<pi, ll> pii; typedef set <ll> si; typedef long double ld; #define f first #define s second #define mp make_pair #define FOR(i,s,e) for(int i=s;i<=int(e);++i) #define DEC(i,s,e) for(int i=s;i>=int(e);--i) #define pb push_back #define all(x) (x).begin(), (x).end() #define lbd(x, y) lower_bound(all(x), y) #define ubd(x, y) upper_bound(all(x), y) #define aFOR(i,x) for (auto i: x) #define mem(x,i) memset(x,i,sizeof x) #define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0) #define maxn 200010 #define INF (ll)1e9 #define MOD 1000000007 typedef pair <vi, int> pvi; typedef pair <int,pi> ipi; typedef vector <pii> vpii; vi labels; int co = 0; vi adj[maxn]; void dfs(int x,int p, bool f){ if (f) labels[x] = co++; aFOR(i, adj[x]) if (i != p) dfs(i,x,!f); if (!f) labels[x] = co++; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { FOR(i,0,n-1) adj[i].clear(); co = 0; FOR(i,0,n-2){ adj[u[i]].pb(v[i]); adj[v[i]].pb(u[i]); } labels = vi(n, 0); dfs(0,-1,1); /* cout << "LABELS: "; aFOR(i, labels) cout << i << ' '; cout << '\n'; */ return labels; } //#include "stations.h" #include <vector> #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pi; typedef vector <int> vi; typedef vector <pi> vpi; typedef pair<pi, ll> pii; typedef set <ll> si; typedef long double ld; #define f first #define s second #define mp make_pair #define FOR(i,s,e) for(int i=s;i<=int(e);++i) #define DEC(i,s,e) for(int i=s;i>=int(e);--i) #define pb push_back #define all(x) (x).begin(), (x).end() #define lbd(x, y) lower_bound(all(x), y) #define ubd(x, y) upper_bound(all(x), y) #define aFOR(i,x) for (auto i: x) #define mem(x,i) memset(x,i,sizeof x) #define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0) #define maxn 200010 #define INF (ll)1e9 #define MOD 1000000007 typedef pair <vi, int> pvi; typedef pair <int,pi> ipi; typedef vector <pii> vpii; int find_next_station(int s, int t, std::vector<int> c) { bool pre = (c[0] > s); if (c.size() == 1) return c[0]; if (pre){ int par = c.back(); c.pop_back(); if (s + 1 <= t && t <= c[0]) return c[0]; FOR(i,1,c.size()-1){ if (c[i-1] + 1 <= t && t <= c[i]) return c[i]; } return par; }else{ int par = c[0]; FOR(i,1,c.size()-2){ if (c[i] <= t && t <= c[i+1] - 1) return c[i]; } if (c.back() <= t && t <= s - 1) return c.back(); return par; } }
#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...