Submission #430707

# Submission time Handle Problem Language Result Execution time Memory
430707 2021-06-17T01:37:23 Z JUANDI321 Stations (IOI20_stations) C++17
0 / 100
1032 ms 59320 KB
#include "stations.h"
#include <vector>
#include <iostream>

using namespace std;
vector<vector<int>> g(1e6+10);
vector<int> l(1e6 +10);
bool ch[1000010];

void dfs(int node)
{
	if(ch[node])return;
	//cout<<"holis"<<endl;
	ch[node]=true;
	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);//cout<<"hola"<<endl;
	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)return 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:41:5: warning: 'spn' may be used uninitialized in this function [-Wmaybe-uninitialized]
   41 |  dfs(spn);//cout<<"hola"<<endl;
      |  ~~~^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 31536 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 31540 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 31564 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1032 ms 59320 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 31588 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -