Submission #217825

# Submission time Handle Problem Language Result Execution time Memory
217825 2020-03-30T22:34:31 Z milagrosvilla1803 Birmingham (COCI20_birmingham) C++11
70 / 70
116 ms 15988 KB
#include <bits/stdc++.h>
using namespace std;
int n,m,q,k;
vector<int>ady[200005];
vector<int>d[100005];
int enterarse[100005];
int distancia[100005];
int aux;
int x,y;
queue<int> fila;
short color[100005];
void bfs(){
    while(!fila.empty()){
        int nodoAct=fila.front(); fila.pop();
        for(int i=0;i<ady[nodoAct].size();i++){
            int hijo=ady[nodoAct][i];
            if(color[hijo]==0){
                color[hijo]=1;
                distancia[hijo]=distancia[nodoAct]+1;
                fila.push(hijo);
            }
        }
        color[nodoAct]=2;
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m>>q>>k;
    memset(enterarse,-1,n);
    for(int i=0;i<q;i++){
        cin>>aux;
        enterarse[aux]=0;
        fila.push(aux);
        color[aux]=1;
        distancia[aux]=0;
    }
    for(int i=0;i<m;i++){
        cin>>x>>y;
        ady[x].push_back(y);
        ady[y].push_back(x);
    }
    bfs();
    for(int i=1;i<=n;i++)
        d[distancia[i]].push_back(i);
    int adj=q,a=1,dia=1;
    int inicio=0;
    while(adj<n){
        while(a<=inicio+k*dia){
            for(int i=0;i<d[a].size();i++){
                adj++;
                enterarse[d[a][i]]=dia;
            }
            a++;
        }
        inicio+=k*dia;
        dia++;
    }
    for(int i=1;i<=n;i++)
        cout<<enterarse[i]<<" ";
    return 0;
}

Compilation message

birmingham.cpp: In function 'void bfs()':
birmingham.cpp:15:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<ady[nodoAct].size();i++){
                     ~^~~~~~~~~~~~~~~~~~~~
birmingham.cpp: In function 'int main()':
birmingham.cpp:50:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int i=0;i<d[a].size();i++){
                         ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 7424 KB Output is correct
2 Correct 8 ms 7424 KB Output is correct
3 Correct 8 ms 7424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 7424 KB Output is correct
2 Correct 9 ms 7424 KB Output is correct
3 Correct 8 ms 7424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7424 KB Output is correct
2 Correct 8 ms 7424 KB Output is correct
3 Correct 8 ms 7424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7424 KB Output is correct
2 Correct 8 ms 7424 KB Output is correct
3 Correct 8 ms 7424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 7424 KB Output is correct
2 Correct 9 ms 7424 KB Output is correct
3 Correct 8 ms 7424 KB Output is correct
4 Correct 9 ms 7424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 7424 KB Output is correct
2 Correct 8 ms 7424 KB Output is correct
3 Correct 11 ms 7424 KB Output is correct
4 Correct 9 ms 7424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7424 KB Output is correct
2 Correct 8 ms 7424 KB Output is correct
3 Correct 9 ms 7424 KB Output is correct
4 Correct 8 ms 7424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 94 ms 13300 KB Output is correct
2 Correct 99 ms 13424 KB Output is correct
3 Correct 103 ms 15984 KB Output is correct
4 Correct 83 ms 14648 KB Output is correct
5 Correct 108 ms 14836 KB Output is correct
6 Correct 107 ms 15988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 101 ms 13408 KB Output is correct
2 Correct 97 ms 13300 KB Output is correct
3 Correct 113 ms 15732 KB Output is correct
4 Correct 102 ms 15860 KB Output is correct
5 Correct 105 ms 15540 KB Output is correct
6 Correct 90 ms 15236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 108 ms 13304 KB Output is correct
2 Correct 104 ms 13460 KB Output is correct
3 Correct 103 ms 15976 KB Output is correct
4 Correct 103 ms 15808 KB Output is correct
5 Correct 103 ms 15224 KB Output is correct
6 Correct 93 ms 15348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 86 ms 13048 KB Output is correct
2 Correct 97 ms 15476 KB Output is correct
3 Correct 116 ms 15864 KB Output is correct
4 Correct 92 ms 15124 KB Output is correct
5 Correct 95 ms 14772 KB Output is correct
6 Correct 90 ms 15224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 89 ms 13044 KB Output is correct
2 Correct 93 ms 13236 KB Output is correct
3 Correct 96 ms 15288 KB Output is correct
4 Correct 93 ms 15092 KB Output is correct
5 Correct 92 ms 15220 KB Output is correct
6 Correct 86 ms 15092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 13048 KB Output is correct
2 Correct 89 ms 13172 KB Output is correct
3 Correct 89 ms 15160 KB Output is correct
4 Correct 113 ms 15476 KB Output is correct
5 Correct 93 ms 15160 KB Output is correct
6 Correct 93 ms 15352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 93 ms 13176 KB Output is correct
2 Correct 81 ms 12920 KB Output is correct
3 Correct 103 ms 15984 KB Output is correct
4 Correct 88 ms 15160 KB Output is correct
5 Correct 94 ms 15328 KB Output is correct
6 Correct 101 ms 15984 KB Output is correct