Submission #430763

# Submission time Handle Problem Language Result Execution time Memory
430763 2021-06-17T03:46:32 Z JUANDI321 Stations (IOI20_stations) C++17
0 / 100
3000 ms 2097156 KB
#include "stations.h"
#include <vector>
#include <iostream>
#include <cstring>
 
using namespace std;
vector<vector<int>> g(1000+10);
vector<int> l(10000 +10);
bool ch[1010];

void dfs(int node, int i, int p)
{
	//if(ch[node])return;
	//ch[node]=true;
	l[node] = i;
	//cout<<node<<endl;
	for(int y : g[node])
	{
		if(y != p)
		{
			dfs(y, i+1, node);
		}
	}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) 
{
	vector<int> labels(n);
	l.resize(n);
	for(int i = 0; i < n-1; i++)
	{
		g[u[i]].push_back(v[i]);
    	g[v[i]].push_back(u[i]);
	}
	int spn = 0;
	for(int i = 0; i < n; i++)
	{
		if(g[i].size() == 1)
		{
			spn = i;
			break;
		}
	}
	dfs(spn, 0, -1);
	//cout<<"hola"<<endl;
	for (int i = 0; i < n; i++) 
	{
		labels[i] = l[i];
		//cout<<"l[i] "<<l[i]<<" lb i "<<labels[l[i]]<<endl;
	}
	//cout<<"---------"<<endl;
	for(int i = 0; i<n+2; i++)ch[i]=false;
	/*for(int i=0; i<n; i++)*/ g.clear(); 
	l.clear();
	return labels;
}
 
int find_next_station(int s, int t, vector<int> c) 
{
	if(t>s)return s+1;
	return s-1;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 480 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3060 ms 2097156 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 476 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1445 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -