#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
typedef pair<ll,ll> pii;
const ll MAXN = 1005;
const ll INF = 1e9+7;
vector<vector<ll>>adj(MAXN);
int deg[MAXN],order[MAXN];
void dfs(int node, int p,int mark){
order[node]=mark;
for(auto u:adj[node]){
if(u==p)continue;
dfs(u,node,mark+1);
}
}
std::vector<int> label(int n, int k,std::vector<int>u,std::vector<int>v){
std::vector<int> labels(n);
int i;
for(i=0;i<n;i++) {
deg[i]=0;
adj[i].clear();
order[i]=0;
}
for(i=0;i<n-1;i++){
adj[u[i]].pb(v[i]);
adj[v[i]].pb(u[i]);
deg[u[i]]++;
deg[v[i]]++;
}
for(i=0;i<n;i++) {
if(deg[i]==1)break;
}
// cout<<i<<" k \n";
dfs(i,-1,0);
for (i = 0; i < n; i++) {
labels[i] = order[i];
// cout<<order[i]<<" ";
}//cout<<endl;
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
int mini=INF,maxi=-1;
for(auto u:c){
mini=min(mini,u);
maxi=max(maxi,u);
}
// sort(c.begin(),c.end());
if(t<s)return mini;
return maxi;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
550 ms |
528 KB |
Output is correct |
2 |
Correct |
458 ms |
612 KB |
Output is correct |
3 |
Correct |
823 ms |
400 KB |
Output is correct |
4 |
Correct |
660 ms |
512 KB |
Output is correct |
5 |
Correct |
570 ms |
400 KB |
Output is correct |
6 |
Correct |
422 ms |
492 KB |
Output is correct |
7 |
Correct |
439 ms |
520 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
5 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
476 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
316 KB |
Invalid labels (duplicates values). scenario=0, label=10 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
529 ms |
528 KB |
Output is correct |
2 |
Correct |
417 ms |
512 KB |
Output is correct |
3 |
Correct |
838 ms |
400 KB |
Output is correct |
4 |
Correct |
613 ms |
516 KB |
Output is correct |
5 |
Correct |
583 ms |
400 KB |
Output is correct |
6 |
Correct |
459 ms |
520 KB |
Output is correct |
7 |
Correct |
432 ms |
528 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
6 ms |
476 KB |
Output is correct |
10 |
Correct |
2 ms |
476 KB |
Output is correct |
11 |
Incorrect |
1 ms |
308 KB |
Invalid labels (duplicates values). scenario=1, label=2 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
820 ms |
400 KB |
Output is correct |
2 |
Correct |
655 ms |
400 KB |
Output is correct |
3 |
Correct |
580 ms |
400 KB |
Output is correct |
4 |
Correct |
3 ms |
468 KB |
Output is correct |
5 |
Correct |
4 ms |
468 KB |
Output is correct |
6 |
Correct |
2 ms |
448 KB |
Output is correct |
7 |
Incorrect |
1 ms |
200 KB |
Invalid labels (duplicates values). scenario=0, label=2 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
529 ms |
512 KB |
Output is correct |
2 |
Correct |
441 ms |
528 KB |
Output is correct |
3 |
Correct |
874 ms |
400 KB |
Output is correct |
4 |
Correct |
638 ms |
512 KB |
Output is correct |
5 |
Correct |
563 ms |
400 KB |
Output is correct |
6 |
Correct |
423 ms |
528 KB |
Output is correct |
7 |
Correct |
431 ms |
516 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
4 ms |
596 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Incorrect |
4 ms |
320 KB |
Invalid labels (duplicates values). scenario=0, label=10 |
12 |
Halted |
0 ms |
0 KB |
- |