Submission #238673

# Submission time Handle Problem Language Result Execution time Memory
238673 2020-06-12T10:16:48 Z Niya_R Birmingham (COCI20_birmingham) C++14
0 / 70
226 ms 7548 KB
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,m,q,k;
vector<int> a[100004];
int used[100004];
int br;
int day=1;
void read()
{
    memset(used,-1,sizeof(used));
    cin>>n>>m>>q>>k;
    br=n-q;
    for(int i=1;i<=q;i++)
    {
        int x;
        cin>>x;
        used[x]=0;
    }
    for(int i=1;i<=m;i++)
    {
        int x,y;
        cin>>x>>y;
        a[x].push_back(y);
        a[y].push_back(x);
    }
    cout<<endl;
}
void dfs(int x, int p)
{
    if(p==0) return;
    else
    {
        p-=1;
        int sz=a[x].size();
        for(int i=0;i<sz;i++)
        {
            int nb=a[x][i];
            if(used[nb]==-1)
            {
                br--;
                used[nb]=day;
                dfs(nb,p);
            }
        }
    }
}
void solve()
{
    while(br>0)
    {
        for(int i=1;i<=n;i++)
        {
            if(used[i]>-1)
            {
                dfs(i,day*k);
            }
        }
        day++;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<used[i]<<" ";
    }
    cout<<endl;
}
int main()
{
    read();
    solve();
 return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 3072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 3104 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 3072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 3072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 3072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 3072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 3072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 204 ms 7288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 219 ms 7548 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 217 ms 7368 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 189 ms 7288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 200 ms 7160 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 199 ms 7164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 226 ms 7240 KB Output isn't correct
2 Halted 0 ms 0 KB -