이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"bits/stdc++.h"
#include "stations.h"
#include <vector>
using namespace std;
const int N = 2000;
int T;
vector<int> adj[N], lb(N);
vector<bool> vis(N);
void dfs(int s, bool b){ //b = 0 apertura, b = 1 chiusura
if(vis[s]) return;
vis[s] = 1;
if(!b) lb[s] = T*2; T++;
for(int u : adj[s]) dfs(u, 1-b);
if(b) lb[s] = T*2+1; T++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
for(int i=0; i<n; ++i) adj[i].clear();
lb.resize(n);
fill(lb.begin(), lb.end(), -1);
fill(vis.begin(), vis.end(), 0);
T = 0;
for(int i=0; i<n-1; ++i){
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs(0, 0);
//for(int i=0; i<n; ++i) cout << i << " " << lb[i] << endl;
return lb;
}
int find_next_station(int s, int t, vector<int> c) {
int par;
if(t%2) t--;
//s apertura
if(s%2==0){
par = 0;
for(int u : c) par = max(par, u);
if(t < s) return par;
for(int u : c) if(u <= t) return u;
return par;
}
// s chiusura
par = 40000;
for(int u : c) par = min(par, u);
if(t > s) return par;
for(int u : c) if(u >= t) return u;
return par;
}
컴파일 시 표준 에러 (stderr) 메시지
stations.cpp: In function 'void dfs(int, bool)':
stations.cpp:15:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
15 | if(!b) lb[s] = T*2; T++;
| ^~
stations.cpp:15:22: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
15 | if(!b) lb[s] = T*2; T++;
| ^
stations.cpp:17:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
17 | if(b) lb[s] = T*2+1; T++;
| ^~
stations.cpp:17:23: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
17 | if(b) lb[s] = T*2+1; T++;
| ^
# | 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... |