Submission #502384

# Submission time Handle Problem Language Result Execution time Memory
502384 2022-01-05T21:00:49 Z inksamurai Birmingham (COCI20_birmingham) C++17
0 / 70
107 ms 8380 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define vec(...) vector<__VA_ARGS__>
#define _3qplfh5 ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;

void print(){
	cout<<"\n";
}
template<class te,class ...ti>
void print(const te&v, const ti&...nv) { 
	cout<<v;
	if(sizeof...(nv)){
		cout<<" ";
		print(nv...);
	}
}

using pii=pair<int,int>;
using vi=vector<int>;
using vll=vector<long long>;

const int inf=1e9;

void slv(){
	int n,m,q,k;
	cin>>n>>m>>q>>k;
	vi rbe(n,0);
	rep(_,q){
		int x;
		cin>>x;
		x--;
		rbe[x]=1;
	}
	vec(vi) adj(n);
	rep(i,m){
		int u,v;
		cin>>u>>v;
		u--,v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	priority_queue<pii,vec(pii),greater<pii>> pq;
	vi dp(n,inf);
	rep(v,n){
		if(rbe[v]){
			pq.push({0,v});
			dp[v]=0;
		}
	}
	while(sz(pq)){
		pii top=pq.top();
		pq.pop();
		int v=top.se,cost=top.fi;
		if(dp[v]!=cost) continue;
		for(auto u : adj[v]){
			if(dp[u]>cost+1){
				dp[u]=cost+1;
				pq.push({cost+1,u});
			}
		}
	}
	rep(v,n){
		int ans=sqrt((dp[v]*2)/k);
		// while(ans*(ans+1)*k<2*dp[v]) ans++;
		// while((ans-1)*ans*k>=2*dp[v]) ans--;
		print(max(0,ans),"");
	}
	print('\n');
}

int main(){
_3qplfh5;
	int t=1;
	// cin>>t;
	rep(cs,t)
		slv();
//	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 98 ms 8100 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 107 ms 8380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 83 ms 8156 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 7848 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 73 ms 7876 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 88 ms 8124 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 77 ms 8000 KB Output isn't correct
2 Halted 0 ms 0 KB -