답안 #517069

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
517069 2022-01-22T13:17:52 Z Sirapetch 기지국 (IOI20_stations) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

vector <int> path[1111];
queue <int> walk;
int pass[1111],label[1111];

vector <int> label(int n, int k, vector<int> u, vector<int> v)
{
    int i,x;
    for(i=0;i<n;i++)
    {
        pass[i]=0;
    }
    for(i=0;i<u.size();i++)
    {
        path[u[i]].push_back(v[i]);
        path[v[i]].push_back(u[i]);
        walk.push(0);
        x=0;
    }
    while(!walk.empty())
    {
        i=walk.front();
        if(pass[i]==1) continue;
        pass[i]=1;
        label[i]=x;
        x++;
        for(auto a:path[i])
        {
            walk.push(a);
        }
    }
    return label;
}

int find_next_station(int s, int t, vector<int> c)
{
    if(s<t) return s+1;
    else return s-1;
}

Compilation message

stations.cpp:8:62: error: 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)' redeclared as different kind of entity
    8 | vector <int> label(int n, int k, vector<int> u, vector<int> v)
      |                                                              ^
stations.cpp:6:16: note: previous declaration 'int label [1111]'
    6 | int pass[1111],label[1111];
      |                ^~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:15:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(i=0;i<u.size();i++)
      |             ~^~~~~~~~~
stations.cpp:34:12: error: could not convert 'label' from 'int [1111]' to 'std::vector<int>'
   34 |     return label;
      |            ^~~~~
      |            |
      |            int [1111]