Submission #299178

#TimeUsernameProblemLanguageResultExecution timeMemory
299178quanmcvnBirmingham (COCI20_birmingham)C++14
15 / 70
184 ms17268 KiB
#include <bits/stdc++.h>
#define fff "main"
#define For(i,a,b) for (auto i = a; i < b; ++i)
#define pb push_back
#define en cout << '\n';
using namespace std;

typedef signed long long int ll;
typedef std::vector<ll> vll;

vector<pair<ll,ll> > ct[100001];
ll d[100001];
ll know_first[100001];
ll n,m,q,k;

void spf(){
	priority_queue<pair<ll, ll >, vector<pair<ll,ll > >, greater<pair<ll, ll > > >pq;
	For (i,1,n+1) {
		d[i] = 99999999999;
		if (know_first[i]){
			d[i] = 0;
			pq.push({0,i});
		}
	}
	while (pq.size()) {
		ll u = pq.top().second;
		ll du = pq.top().first;
		pq.pop();
		if (du > d[u]) continue;
		for (ll i = 0; i < ct[u].size(); i++) {
			ll v = ct[u][i].second;
			ll w = ct[u][i].first;
			if (d[v] > du + w) {
				d[v] = du + w;
				pq.push({d[v], v});
			}
		}
	}
}

int main()
{
//	if (fopen(fff".inp","r")) {
//		freopen(fff".inp","r",stdin);
//		freopen(fff".out","w",stdout);
//	}
	ios_base :: sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> m >> q >> k;
	while (q--) {
		ll f;
		cin >> f;
		know_first[f] = 1;
	}
	while (m--){
		ll u, v; cin >> u >> v;
		ct[u].pb({1,v});
		ct[v].pb({1,u});
	}
	spf();
	For (i,1,n+1){
		cout << (d[i] + k - 1) / k << ' ';
	}
    return 0;
}

Compilation message (stderr)

birmingham.cpp: In function 'void spf()':
birmingham.cpp:30:20: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   for (ll i = 0; i < ct[u].size(); i++) {
      |                  ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...