답안 #373949

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
373949 2021-03-06T09:24:31 Z Jarif_Rahman 기지국 (IOI20_stations) C++17
컴파일 오류
0 ms 0 KB
#include "stations.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
vector<vector<int>> v;
vector<int> lb, sz;
int in = 0;
void dfs(int nd, int ss, int d){
    if(d%2 == 0) lb[nd] = in;
    in++;
    for(int x: v[nd]) if(x != ss) dfs(x, nd, d+1);
    if(d%2 == 1) lb[nd] = in;
    in++
}
vector<int> label(int n, int k, vector<int> aa, vector<int> bb){
    in = 0;
    v.assign(n, {});
    lb.assign(n, -1);
    for(int i = 0; i < n-1; i++){
        v[aa[i]].pb(bb[i]);
        v[bb[i]].pb(aa[i]);
    }
    dfs(0, -1);
    return lb;
}
int find_next_station(int s, int t, vector<int> c){
    sort(c.begin(), c.end());
    if(s > c[0]){
        c.pb(s);
        for(int i = 1; i < (int)c.size() - 1; i++){
            if(t >= c[i] && t < c[i+1]) return c[i];
        }
        return c[0];
    }
    else{
        reverse(c.begin(). c.end());
        c.pb(s);
        for(int i = (s==0); i < (int)c.size()-1; i++){
            if(t <= c[i] && t > c[i+1]) return c[i];
        }
        return c[0];
    }
}

Compilation message

stations.cpp: In function 'void dfs(int, int, int)':
stations.cpp:17:9: error: expected ';' before '}' token
   17 |     in++
      |         ^
      |         ;
   18 | }
      | ~        
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:27:14: error: too few arguments to function 'void dfs(int, int, int)'
   27 |     dfs(0, -1);
      |              ^
stations.cpp:12:6: note: declared here
   12 | void dfs(int nd, int ss, int d){
      |      ^~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:40:28: error: 'std::vector<int>::iterator' {aka 'class __gnu_cxx::__normal_iterator<int*, std::vector<int> >'} has no member named 'c'
   40 |         reverse(c.begin(). c.end());
      |                            ^