# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1064678 |
2024-08-18T16:43:23 Z |
XJP12 |
Stations (IOI20_stations) |
C++14 |
|
1 ms |
344 KB |
#include <bits/stdc++.h>
#include "stations.h"
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
vvi g;
vi vis;
vi l;
vi indeg;
int y=-1;
int cont=0;
void dfs1(int u, int p){
vis[u]=true;
if(u==y){
l[u]=1000+l[p];
}else{
l[u]=cont;
cont++;
}
for(auto v: g[u]){
if(!vis[v]){
dfs1(v,u);
}
}
}
void dfs(int u){
vis[u]=true;
l[u]=cont;
cont++;
for(auto v: g[u]){
if(!vis[v]){
dfs(v);
}
}
}
vi label(int n, int k, vi u, vi v) {
l.resize(n+1,0);
vis.resize(n+1,0);
indeg.resize(n+1,0);
g.resize(n+1, vi());
for(int i=0; i<n-1; i++){
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
indeg[u[i]]++;
indeg[v[i]]++;
}
int x=-1;
for(int i=0; i<n; i++){
if(indeg[i]==1 && indeg[g[i][0]]!=3) x=i;
if((indeg[i]==1 && indeg[g[i][0]]==3)) y=i;
}
if(k>1000 && y!=-1){
dfs1(x,x);
}else{
dfs(x);
}
return l;
}
int find_next_station(int s, int t, vi c) {
int size = (int)c.size();
if(size==1)return c[0];
for(int i=0; i<size; i++){
if(c[i]==t) return c[i];
}
if(s<=1000 && t<=1000){
if(t>s){
return c[1];
}else{
return c[0];
}
}else{
if(t-1000>s){
return c[1];
}else{
return c[0];
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Invalid length of array as the response of 'label'. scenario=0, n=10, len=11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Invalid length of array as the response of 'label'. scenario=0, n=996, len=997 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Invalid length of array as the response of 'label'. scenario=0, n=2, len=3 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Invalid length of array as the response of 'label'. scenario=0, n=2, len=3 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Invalid length of array as the response of 'label'. scenario=0, n=3, len=4 |
2 |
Halted |
0 ms |
0 KB |
- |