이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
using namespace std;
const int mod = 1000000007;
void add(int& a, int b) {
a += b;
if (a >= mod) a -= mod;
if (a < 0) a += mod;
}
int mult(int a, int b) {
return a * (ll)b % mod;
}
int bp(int a, int b) {
int res = 1;
while (b > 0) {
if (b & 1) res = mult(res, a);
a = mult(a, a);
b >>= 1;
}
return res;
}
vector<vector<int> > gr;
vector<int> ans;
int timer;
void dfs(int vertex, int last, int d) {
if (d%2==0) ans[vertex] = timer++;
for (auto to : gr[vertex]) {
if (to==last) continue;
dfs(to, vertex, d+1);
}
if (d%2!=0) ans[vertex] = timer++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
gr.assign(n, {});
timer = 0;
for (int i = 0; i < n-1; ++i) {
gr[u[i]].pb(v[i]);
gr[v[i]].pb(u[i]);
}
ans.assign(n, -1);
dfs(0, -1, 0);
return ans;
}
int find_next_station(int s, int t, vector<int> c) {
if (s < c[0]) {
int last = s;
for (int i = 0; i + 1 < c.size(); ++i) {
auto x = c[i];
if (t > last && t <= x) return x;
last = x;
}
return c.back();
}
else {
int last = s;
for (int i = c.size() - 1; i >= 0; --i) {
auto x = c[i];
if (t >= x && t < last) return x;
last = x;
}
return c[0];
}
}
#ifdef LOCAL
int main(){
freopen("D_input.txt", "r", stdin);
//freopen("D_output.txt", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
}
#endif
컴파일 시 표준 에러 (stderr) 메시지
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:68:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
68 | for (int i = 0; i + 1 < c.size(); ++i) {
| ~~~~~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |