Submission #930135

#TimeUsernameProblemLanguageResultExecution timeMemory
930135quanlt206Stations (IOI20_stations)C++17
0 / 100
1 ms544 KiB
#include "stations.h" #include<bits/stdc++.h> #define X first #define Y second #define all(x) begin(x), end(x) #define FOR(i, a, b) for(int i = (a); i <= (b); i++) #define FORD(i, b, a) for(int i = (b); i >= (a); i--) #define REP(i, a, b) for (int i = (a); i < (b); i++) #define mxx max_element #define mnn min_element #define SQR(x) (1LL * (x) * (x)) #define MASK(i) (1LL << (i)) #define Point Vector #define left Left #define right Right #define div Div using namespace std; typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ld; typedef pair<db, db> pdb; typedef pair<ld, ld> pld; typedef pair<int, int> pii; typedef pair<int, pii> piii; typedef pair<ll, ll> pll; typedef pair<ll, pll> plll; typedef pair<ll, int> pli; typedef pair<ll, pii> plii; template<class A, class B> bool maximize(A& x, B y) { if (x < y) return x = y, true; else return false; } template<class A, class B> bool minimize(A& x, B y) { if (x > y) return x = y, true; else return false; } /* END OF TEMPLATE */ const int N = 1e3 + 7; vector<int> v[N]; int st[N], ed[N], cnt = 0, high[N]; int lab[N]; void dfs(int x, int par) { st[x] = ++cnt; for (auto y : v[x]) if (y != par) { high[y] = high[x] + 1; dfs(y, x); } ed[x] = ++cnt; } vector<int> label(int n, int k, vector<int> a, vector<int> b) { REP(i, 0, n) v[i].clear(); REP(i, 0, n - 1) { v[a[i]].push_back(b[i]); v[b[i]].push_back(a[i]); } cnt = 0; dfs(0, 0); REP(i, 0, n) if (high[i] == 0) lab[i] = st[i]; else lab[i] = ed[i]; vector<int> res(lab, lab + n); for (auto x : res) cout<<x<<" "; cout<<"\n"; return res; } int find_next_station(int s, int t, vector<int> c) { sort(all(c)); if (binary_search(all(c), t)) return t; int n = c.size(); if (s < c[0]) { // s thoi diem vao if (s != 0) { // check xem t co nam ngoai cay con goc s hay khong if (t < s || t > c[n - 2]) return c[n - 1]; // return cha } for (auto x : c) if (x > t) return x; } // s thoi diem ra if (s != 0) { if (t > s || t < c[1]) return c[0]; } int res = 0; for (auto x : c) if (x <= t) res = x; return res; }

Compilation message (stderr)

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:71:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   71 |     for (auto x : res) cout<<x<<" "; cout<<"\n";
      |     ^~~
stations.cpp:71:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   71 |     for (auto x : res) cout<<x<<" "; cout<<"\n";
      |                                      ^~~~
#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...