Submission #430704

# Submission time Handle Problem Language Result Execution time Memory
430704 2021-06-17T01:24:00 Z JUANDI321 Stations (IOI20_stations) C++17
0 / 100
1 ms 408 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:34:5: warning: 'spn' may be used uninitialized in this function [-Wmaybe-uninitialized]
   34 |  dfs(spn);
      |  ~~~^~~~~
# 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 408 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 284 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 268 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 268 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -