답안 #238688

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
238688 2020-06-12T11:04:57 Z Niya_R Birmingham (COCI20_birmingham) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,m,q,k;
vector<int> a[100004];
int used[100004];
int br;
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);
    }
}
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()
{

    queue<int>q1;
    int day=1;
    while(br>0)
    {
        for(int i=1; i<=n; i++)
        {
            if(used[i]>-1)
            {
                q1.push(i);
            }
        }
        while(!q1.empty())
        {
            int x=q1.front();
            q1.pop();
            dfs(x,day*k);
        }
        day++;
    }
    for(int i=1; i<=n; i++)
    {
        cout<<used[i]<<" ";
    }
    cout<<endl;
}
int main()
{
    read();
    solve();
    return 0;
}

Compilation message

birmingham.cpp: In function 'void dfs(int, int)':
birmingham.cpp:41:26: error: 'day' was not declared in this scope
                 used[nb]=day;
                          ^~~