답안 #845387

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845387 2023-09-06T13:26:24 Z vjudge1 Birmingham (COCI20_birmingham) C++17
70 / 70
153 ms 14136 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
	int n, m, _q, k;
	cin>>n>>m>>_q>>k;
	vector<vector<int>> arr(n);
	queue<pair<int,int>> q;
	for (int i = 0; i < _q; ++i)
	{
		int x;cin>>x;
		q.push({x-1,0});
	}
	for (int i = 0; i < m; i++){
		int u,v;cin>>u>>v;
		arr[u-1].push_back(v-1);
		arr[v-1].push_back(u-1);
	}
	vector<int> dp(n,-1);
	while (q.size()){
		int node = q.front().first;
		int w = q.front().second;
		q.pop();
		if (dp[node]!=-1) continue;
		dp[node]=w;
		for (int i = 0; i < arr[node].size(); i++){
			if (dp[arr[node][i]]!=-1) continue;
			q.push({arr[node][i],w+1});
		}
	}
	for (int i = 0; i < dp.size(); i++){
		int cnt = (dp[i]+k-1)/k;
		int x = max(0ll,(int)sqrt(cnt)-5);
		while (x*(x+1)/2<cnt){
			x++;
		}
		cout<<x<<" ";
	}
	cout<<endl;
}

Compilation message

birmingham.cpp: In function 'int32_t main()':
birmingham.cpp:26:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for (int i = 0; i < arr[node].size(); i++){
      |                   ~~^~~~~~~~~~~~~~~~~~
birmingham.cpp:31:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for (int i = 0; i < dp.size(); i++){
      |                  ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 139 ms 11860 KB Output is correct
2 Correct 117 ms 12868 KB Output is correct
3 Correct 135 ms 13784 KB Output is correct
4 Correct 106 ms 11012 KB Output is correct
5 Correct 97 ms 11220 KB Output is correct
6 Correct 125 ms 14136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 125 ms 12560 KB Output is correct
2 Correct 114 ms 12468 KB Output is correct
3 Correct 126 ms 13144 KB Output is correct
4 Correct 120 ms 13080 KB Output is correct
5 Correct 129 ms 12588 KB Output is correct
6 Correct 119 ms 12816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 129 ms 12040 KB Output is correct
2 Correct 137 ms 13060 KB Output is correct
3 Correct 153 ms 13904 KB Output is correct
4 Correct 135 ms 13076 KB Output is correct
5 Correct 131 ms 11700 KB Output is correct
6 Correct 113 ms 12924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 97 ms 11428 KB Output is correct
2 Correct 116 ms 12400 KB Output is correct
3 Correct 132 ms 13464 KB Output is correct
4 Correct 105 ms 11856 KB Output is correct
5 Correct 104 ms 11236 KB Output is correct
6 Correct 113 ms 12612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 109 ms 11332 KB Output is correct
2 Correct 124 ms 11756 KB Output is correct
3 Correct 139 ms 12280 KB Output is correct
4 Correct 108 ms 11600 KB Output is correct
5 Correct 106 ms 11780 KB Output is correct
6 Correct 133 ms 12624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 101 ms 11600 KB Output is correct
2 Correct 114 ms 11860 KB Output is correct
3 Correct 106 ms 12628 KB Output is correct
4 Correct 132 ms 12424 KB Output is correct
5 Correct 116 ms 11580 KB Output is correct
6 Correct 123 ms 12884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 11608 KB Output is correct
2 Correct 139 ms 11160 KB Output is correct
3 Correct 143 ms 13684 KB Output is correct
4 Correct 124 ms 11516 KB Output is correct
5 Correct 115 ms 11924 KB Output is correct
6 Correct 137 ms 14072 KB Output is correct