답안 #238422

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
238422 2020-06-11T07:48:47 Z stev2005 Birmingham (COCI20_birmingham) C++17
15 / 70
138 ms 8532 KB
#include<vector>
#include<queue>
#include<cstdio>
using namespace std;
const int MAXN=(1<<17);
int n,m,q1,k;
int q_el[MAXN],used[MAXN];
vector<int>v[MAXN];
void read()
{
	scanf("%d%d%d%d",&n,&m,&q1,&k);
	for(int i=0;i<q1;i++)
		scanf("%d",&q_el[i]);
	int x,y;
	for(int i=0;i<m;i++)
	{
		scanf("%d%d",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
}
void BFS()
{
	 queue<int>q;
	 int w,nb,i,sz;
	 for(int i=0;i<q1;i++)
	 {
	 	q.push(q_el[i]);
	 	used[q_el[i]]=1;
	 }
	 while(!q.empty())
	 {
	 	w=q.front();
	 	q.pop();
	 	sz=v[w].size();
	 	for(i=0;i<sz;i++)
	 	{
	 		nb=v[w][i];
	 		if(!used[nb])
	 		{
	 			used[nb]=used[w]+1;
	 			q.push(nb);
	 		}
	 	}
	 }
}
void ans()
{
	int rez;
	for(int i=1;i<=n;i++)
	{
		rez=used[i]-1;
		rez=(rez%k)?rez/k+1:rez/k;
		printf("%d ",rez);
	}
}
int main()
{
	read();
	BFS();
	ans();
return 0;
}

Compilation message

birmingham.cpp: In function 'void read()':
birmingham.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d",&n,&m,&q1,&k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
birmingham.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&q_el[i]);
   ~~~~~^~~~~~~~~~~~~~~
birmingham.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&x,&y);
   ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 3456 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 3456 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 3456 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 3456 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3328 KB Output is correct
2 Correct 6 ms 3328 KB Output is correct
3 Correct 6 ms 3456 KB Output is correct
4 Correct 6 ms 3328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3456 KB Output is correct
2 Correct 7 ms 3456 KB Output is correct
3 Correct 6 ms 3456 KB Output is correct
4 Correct 6 ms 3328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3328 KB Output is correct
2 Correct 6 ms 3456 KB Output is correct
3 Correct 6 ms 3328 KB Output is correct
4 Correct 6 ms 3456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 117 ms 8172 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 138 ms 8532 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 106 ms 8152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 98 ms 8040 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 129 ms 7976 KB Output is correct
2 Incorrect 132 ms 8288 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 108 ms 8040 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 119 ms 8160 KB Output isn't correct
2 Halted 0 ms 0 KB -