Submission #502381

# Submission time Handle Problem Language Result Execution time Memory
502381 2022-01-05T20:59:47 Z inksamurai Birmingham (COCI20_birmingham) C++17
35 / 70
1000 ms 11060 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=(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 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 3 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 312 KB Output is correct
3 Correct 3 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 3 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 3 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 78 ms 10052 KB Output is correct
2 Correct 89 ms 10528 KB Output is correct
3 Execution timed out 1039 ms 10948 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 90 ms 10556 KB Output is correct
2 Correct 84 ms 10408 KB Output is correct
3 Execution timed out 1055 ms 10636 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 91 ms 10172 KB Output is correct
2 Correct 86 ms 10624 KB Output is correct
3 Execution timed out 1033 ms 11060 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 75 ms 9692 KB Output is correct
2 Correct 85 ms 10316 KB Output is correct
3 Execution timed out 1018 ms 10696 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 78 ms 9784 KB Output is correct
2 Correct 77 ms 10160 KB Output is correct
3 Correct 981 ms 10484 KB Output is correct
4 Correct 82 ms 9912 KB Output is correct
5 Correct 81 ms 10012 KB Output is correct
6 Execution timed out 1061 ms 10392 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 86 ms 9948 KB Output is correct
2 Correct 94 ms 10116 KB Output is correct
3 Execution timed out 1033 ms 10060 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 79 ms 9952 KB Output is correct
2 Correct 76 ms 9628 KB Output is correct
3 Execution timed out 1035 ms 10892 KB Time limit exceeded
4 Halted 0 ms 0 KB -