Submission #238553

# Submission time Handle Problem Language Result Execution time Memory
238553 2020-06-11T18:59:13 Z Borbi Birmingham (COCI20_birmingham) C++14
0 / 70
131 ms 8696 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 5;

int n, m, f, k;

vector <int> graph[MAXN];

queue <int> q;

int vis[MAXN];
int lvl[MAXN];

void read_input()
{
	cin >> n >> m >> f >> k;
	
	for(int i = 1; i <= n; i++)
	{
		vis[i] = -1;
		lvl[i] = -1;
	}
	int h;
	for(int i = 0; i < f; i++)
	{
		cin >> h;
		q.push(h);
		lvl[h] = 0;
		vis[h] = 0;
	}
	int v, w;
	for(int i = 0; i < m; i++)
	{
		cin >> v >> w;
		graph[v].push_back(w);
		graph[w].push_back(v);
	}
}


void solve()
{
	while(!q.empty())
	{
		int v = q.front(); q.pop();

		cout << v << "\n";

		int new_l = lvl[v];
		int ost = vis[v] - 1;
		if(ost < 0) 
		{	
			new_l++;
			ost = k * new_l;
			ost--;
	
			//cout << " " << v << " " << vis[v] << " " << new_l << " " << ost << "\n";
		}
		for(auto x : graph[v])
		{
			if(vis[x] == -1)
			{
				//cout << "DAS";
				lvl[x] = new_l;
				vis[x] = ost;
				q.push(x);
			}
		}
	}
	for(int i = 1; i <= n; i++)
	{
		cout << lvl[i] << " ";
	}
	cout << "\n";
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	read_input();
	solve();

	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 109 ms 8416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 131 ms 8696 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 117 ms 8440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 105 ms 8312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 101 ms 8312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 101 ms 8312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 122 ms 8440 KB Output isn't correct
2 Halted 0 ms 0 KB -