Submission #502386

# Submission time Handle Problem Language Result Execution time Memory
502386 2022-01-05T21:01:46 Z inksamurai Birmingham (COCI20_birmingham) C++17
0 / 70
1000 ms 8384 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){
		ll ans=sqrt((dp[v]*2)/k);
		while(ans*(ans+1)*(ll)k<2ll*(ll)dp[v]) ans++;
		while((ans-1)*ans*(ll)k>=2ll*(ll)dp[v]) ans--;
		print(max(0ll,ans),"");
	}
	print('\n');
}

int main(){
_3qplfh5;
	int t=1;
	// cin>>t;
	rep(cs,t)
		slv();
//	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1099 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1096 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 725 ms 296 KB Output is correct
2 Execution timed out 1092 ms 204 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 910 ms 296 KB Output is correct
2 Execution timed out 1096 ms 204 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 727 ms 292 KB Output is correct
2 Execution timed out 1099 ms 204 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 955 ms 8092 KB Output is correct
2 Execution timed out 1088 ms 8272 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 903 ms 8376 KB Output is correct
2 Execution timed out 1084 ms 8184 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 976 ms 8128 KB Output is correct
2 Execution timed out 1078 ms 8384 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1057 ms 7880 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 857 ms 8000 KB Output is correct
2 Execution timed out 1089 ms 8244 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 864 ms 7956 KB Output is correct
2 Execution timed out 1050 ms 8128 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 868 ms 8040 KB Output is correct
2 Execution timed out 1090 ms 7872 KB Time limit exceeded
3 Halted 0 ms 0 KB -