제출 #674149

#제출 시각아이디문제언어결과실행 시간메모리
674149Essa2006Stations (IOI20_stations)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
vector<int>Vis, new_;
vector<vector<int>>A;
int time;
void dfs(int ind){
    Vis[ind]=1, new_[ind]=time_++;
    for(int i=0;i<A[ind].size();i++)
        if(!Vis[A[ind][i]])
            dfs(A[ind][i]);
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
    Vis.clear(), A.clear(), new_.clear();
    Vis.resize(n), A.resize(n), new_.resize(n);
    time_=0;
    for(int i=0;i<n-1;i++)
        A[u[i]].push_back(v[i]), A[v[i]].push_back(u[i]);
    for(int i=0;i<n;i++){
        if(A[i].size()==1){
            dfs(i);
            break;
        }
    }
    return new_;
}
int find_next_station(int s, int t, vector<int> c) {
    if(!s)
        return c[0];
    return c[(t>s)];
}

컴파일 시 표준 에러 (stderr) 메시지

stations.cpp:5:5: error: 'int time' redeclared as different kind of entity
    5 | int time;
      |     ^~~~
In file included from /usr/include/c++/10/ctime:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:49,
                 from stations.cpp:1:
/usr/include/time.h:75:15: note: previous declaration 'time_t time(time_t*)'
   75 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
stations.cpp: In function 'void dfs(int)':
stations.cpp:7:27: error: 'time_' was not declared in this scope; did you mean 'time'?
    7 |     Vis[ind]=1, new_[ind]=time_++;
      |                           ^~~~~
      |                           time
stations.cpp:8:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for(int i=0;i<A[ind].size();i++)
      |                 ~^~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:15:5: error: 'time_' was not declared in this scope; did you mean 'time'?
   15 |     time_=0;
      |     ^~~~~
      |     time