답안 #710039

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
710039 2023-03-15T03:57:53 Z ToroTN Birmingham (COCI20_birmingham) C++14
70 / 70
121 ms 9960 KB
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int n,m,num,a,u_i,v_i,k,d[100005],u,hsh[100005],sum=0;
vector<int> v[100005];
queue<int> q;
int main()
{
    memset(d,-1,sizeof d);
    scanf("%d%d%d%d",&n,&m,&num,&k);
    for(int i=1;i<=100000;i++)
    {
        for(int j=1;j<=k*i;j++)
        {
            ++sum;
            //printf("%d %d\n",i,j);
            //printf("%d\n",sum);
            hsh[sum]=i;
            if(sum==100000)break;
        }
        if(sum==100000)break;
    }
    for(int i=1;i<=num;i++)
    {
        scanf("%d",&a);
        d[a]=0;
        q.push(a);
    }
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&u_i,&v_i);
        v[u_i].pb(v_i);
        v[v_i].pb(u_i);
    }
    while(!q.empty())
    {
        u=q.front();
        //printf("%d %d\n",u,d[u]);
        q.pop();
        for(auto node:v[u])
        {
            if(d[node]==-1)
            {
                d[node]=d[u]+1;
                q.push(node);
            }
        }
    }
    //printf("%d\n",d[4]);
    for(int i=1;i<=n;i++)
    {
        printf("%d ",hsh[d[i]]);
    }
    printf("\n");
}

Compilation message

birmingham.cpp: In function 'int main()':
birmingham.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d%d%d%d",&n,&m,&num,&k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
birmingham.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         scanf("%d",&a);
      |         ~~~~~^~~~~~~~~
birmingham.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         scanf("%d%d",&u_i,&v_i);
      |         ~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3412 KB Output is correct
2 Correct 3 ms 3428 KB Output is correct
3 Correct 2 ms 3428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3412 KB Output is correct
2 Correct 2 ms 3412 KB Output is correct
3 Correct 2 ms 3412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3412 KB Output is correct
2 Correct 2 ms 3428 KB Output is correct
3 Correct 2 ms 3412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3432 KB Output is correct
2 Correct 2 ms 3412 KB Output is correct
3 Correct 2 ms 3412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3412 KB Output is correct
2 Correct 3 ms 3372 KB Output is correct
3 Correct 3 ms 3412 KB Output is correct
4 Correct 3 ms 3428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 3412 KB Output is correct
2 Correct 3 ms 3432 KB Output is correct
3 Correct 2 ms 3436 KB Output is correct
4 Correct 2 ms 3428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3412 KB Output is correct
2 Correct 2 ms 3412 KB Output is correct
3 Correct 2 ms 3412 KB Output is correct
4 Correct 2 ms 3412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 98 ms 9304 KB Output is correct
2 Correct 121 ms 9808 KB Output is correct
3 Correct 86 ms 9960 KB Output is correct
4 Correct 76 ms 8720 KB Output is correct
5 Correct 79 ms 9156 KB Output is correct
6 Correct 118 ms 9872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 9760 KB Output is correct
2 Correct 92 ms 9608 KB Output is correct
3 Correct 89 ms 9800 KB Output is correct
4 Correct 103 ms 9928 KB Output is correct
5 Correct 79 ms 9592 KB Output is correct
6 Correct 75 ms 9452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 95 ms 9416 KB Output is correct
2 Correct 120 ms 9940 KB Output is correct
3 Correct 102 ms 9828 KB Output is correct
4 Correct 95 ms 9816 KB Output is correct
5 Correct 71 ms 9156 KB Output is correct
6 Correct 107 ms 9424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 9036 KB Output is correct
2 Correct 93 ms 9532 KB Output is correct
3 Correct 105 ms 9836 KB Output is correct
4 Correct 91 ms 9268 KB Output is correct
5 Correct 73 ms 8920 KB Output is correct
6 Correct 87 ms 9420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 78 ms 8988 KB Output is correct
2 Correct 92 ms 9320 KB Output is correct
3 Correct 77 ms 9376 KB Output is correct
4 Correct 78 ms 9164 KB Output is correct
5 Correct 81 ms 9240 KB Output is correct
6 Correct 78 ms 9308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 9048 KB Output is correct
2 Correct 105 ms 9384 KB Output is correct
3 Correct 107 ms 9268 KB Output is correct
4 Correct 82 ms 9572 KB Output is correct
5 Correct 120 ms 9220 KB Output is correct
6 Correct 93 ms 9500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 92 ms 9140 KB Output is correct
2 Correct 99 ms 8768 KB Output is correct
3 Correct 106 ms 9932 KB Output is correct
4 Correct 98 ms 9324 KB Output is correct
5 Correct 116 ms 9424 KB Output is correct
6 Correct 99 ms 9836 KB Output is correct