답안 #238700

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
238700 2020-06-12T11:37:02 Z Niya_R Birmingham (COCI20_birmingham) C++14
70 / 70
265 ms 9252 KB
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
vector<int>v[100004];
queue<int>q1;
int used[100004];
int ans[100004];
void bfs()
{
    while(!q1.empty())
    {
        int x=q1.front();
        q1.pop();
        int sz=v[x].size();
        for(int i=0;i<sz;i++)
        {
            int nb=v[x][i];
            if(used[nb]==-1)
            {
                used[nb]=used[x]+1;
                q1.push(nb);
            }
        }
    }
}
int main()
{
    int n, m, q, k;
    cin>>n>>m>>q>>k;
    memset(used,-1,sizeof(used));
    for(int i=1; i<=q; i++)
    {
        int x;
        cin>>x;
        used[x]=0;
        ans[x]=0;
        q1.push(x);
    }
    for(int i=1; i<=m; i++)
    {
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    bfs();
    int br=q;
    for(int i=1;i<=200000;i++)
    {
         int l=0;
        for(int j=1;j<=n;j++)
        {
            if(used[j]>0)
            {
                l=1;
                used[j]-=i*k;
                if(used[j]<=0) ans[j]=i;
            }
        }
          if(l==0) break;
    }
    for(int i=1;i<=n;i++)
        cout<<ans[i]<<" ";
    cout<<endl;
    return 0;
}

Compilation message

birmingham.cpp: In function 'int main()':
birmingham.cpp:47:9: warning: unused variable 'br' [-Wunused-variable]
     int br=q;
         ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3072 KB Output is correct
2 Correct 6 ms 3072 KB Output is correct
3 Correct 6 ms 3072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3072 KB Output is correct
2 Correct 6 ms 3072 KB Output is correct
3 Correct 6 ms 3072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 3072 KB Output is correct
2 Correct 6 ms 3072 KB Output is correct
3 Correct 6 ms 3072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3072 KB Output is correct
2 Correct 6 ms 3072 KB Output is correct
3 Correct 6 ms 3072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3072 KB Output is correct
2 Correct 6 ms 3072 KB Output is correct
3 Correct 6 ms 3072 KB Output is correct
4 Correct 6 ms 3072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3072 KB Output is correct
2 Correct 6 ms 3072 KB Output is correct
3 Correct 7 ms 3072 KB Output is correct
4 Correct 6 ms 3072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3072 KB Output is correct
2 Correct 7 ms 3200 KB Output is correct
3 Correct 6 ms 3072 KB Output is correct
4 Correct 6 ms 3072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 198 ms 7824 KB Output is correct
2 Correct 261 ms 9156 KB Output is correct
3 Correct 265 ms 9208 KB Output is correct
4 Correct 180 ms 8572 KB Output is correct
5 Correct 181 ms 8696 KB Output is correct
6 Correct 240 ms 9212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 218 ms 8056 KB Output is correct
2 Correct 211 ms 9020 KB Output is correct
3 Correct 230 ms 9080 KB Output is correct
4 Correct 229 ms 9080 KB Output is correct
5 Correct 207 ms 8952 KB Output is correct
6 Correct 212 ms 8696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 202 ms 7928 KB Output is correct
2 Correct 224 ms 9084 KB Output is correct
3 Correct 244 ms 9252 KB Output is correct
4 Correct 221 ms 9208 KB Output is correct
5 Correct 194 ms 8824 KB Output is correct
6 Correct 210 ms 8932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 190 ms 7672 KB Output is correct
2 Correct 205 ms 8952 KB Output is correct
3 Correct 233 ms 9080 KB Output is correct
4 Correct 198 ms 8952 KB Output is correct
5 Correct 188 ms 8696 KB Output is correct
6 Correct 211 ms 8796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 189 ms 7672 KB Output is correct
2 Correct 204 ms 8952 KB Output is correct
3 Correct 212 ms 8952 KB Output is correct
4 Correct 188 ms 8824 KB Output is correct
5 Correct 196 ms 8824 KB Output is correct
6 Correct 209 ms 8696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 197 ms 7732 KB Output is correct
2 Correct 211 ms 8884 KB Output is correct
3 Correct 206 ms 8824 KB Output is correct
4 Correct 216 ms 9080 KB Output is correct
5 Correct 202 ms 8824 KB Output is correct
6 Correct 216 ms 8772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 198 ms 7800 KB Output is correct
2 Correct 196 ms 8668 KB Output is correct
3 Correct 238 ms 9080 KB Output is correct
4 Correct 198 ms 8824 KB Output is correct
5 Correct 208 ms 8952 KB Output is correct
6 Correct 243 ms 9208 KB Output is correct