Submission #430705

# Submission time Handle Problem Language Result Execution time Memory
430705 2021-06-17T01:26:03 Z JUANDI321 Stations (IOI20_stations) C++17
0 / 100
1 ms 328 KB
#include "stations.h"
#include <vector>

using namespace std;
vector<vector<int>> g;
vector<int> l;
bool ch[1000010];

void dfs(int node)
{
	if(ch[node])return;
	l.push_back(node);
	for(auto y : g[node])
	{
		if(!ch[y])
		{
			dfs(y);
		}
	}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	vector<int> labels(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;
	for(int i = 0; i < n; i++)
	{
		if(g[i].size() == 1)
		{
			spn = i;
			break;
		}
	}
	dfs(spn);
	for (int i = 0; i < n; i++) {
		labels[l[i]] = i;
	}
	return labels;
}

int find_next_station(int s, int t, vector<int> c) 
{
	if(t>s)c[1];
	return c[0];
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:37:5: warning: 'spn' may be used uninitialized in this function [-Wmaybe-uninitialized]
   37 |  dfs(spn);
      |  ~~~^~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 328 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 320 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 280 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 272 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 320 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -