This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "stations.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
#define debug(x) {cerr<<#x<<"="<<x<<"\n";}
#define debug2(x, y) {cerr<<"{"<<#x<<", "<<#y<<"}={"<<x<<", "<<y<<"}\n";}
#define debugp(p) {cerr<<#p<<"={"<<p.first<<", "<<p.second<<"}\n";}
#define debugv(abcd) {cerr<<#abcd<<": "; for (auto dcba:abcd) cerr<<dcba<<", ";cerr<<"\n";}
#define pb push_back
#define all(x) x.begin(), x.end()
#define SZ(x) ((int)x.size())
const int inf=1000000100; // 1e9
const ll INF=10000000001000000; // 1e16
const int mod=1000000007;
const int MAXN=1010;
int n, m, k, x, y, a, b, t, ans;
vi G[MAXN];
vi label(int _n, int _k, vi U, vi V){
n=_n;
k=_k;
vi out(n);
for (int i=0; i<n; i++) G[i].clear();
for (int i=0; i<n-1; i++){
int u=U[i], v=V[i];
G[u].pb(v);
G[v].pb(u);
}
int v, last;
for (int i=0; i<n; i++) if (SZ(G[i])==1) v=last=i;
for (int i=0; i<n; i++){
out[v]=i;
for (int u:G[v]) if (u!=last){
last=v;
v=u;
break ;
}
}
return out;
}
int find_next_station(int s, int t, vi adj){
if (s<t) return s+1;
return s-1;
}
Compilation message (stderr)
stations.cpp: In function 'vi label(int, int, vi, vi)':
stations.cpp:40:20: warning: 'last' may be used uninitialized in this function [-Wmaybe-uninitialized]
40 | for (int u:G[v]) if (u!=last){
| ^~
stations.cpp:39:8: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
39 | out[v]=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... |