답안 #333458

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
333458 2020-12-06T05:57:52 Z sabamaku 기지국 (IOI20_stations) C++14
컴파일 오류
0 ms 0 KB
#include "stations.h"
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;

int cnt;

pair <int,int> d[20005];

vector <int> vi[2005];

void dfs(int x,int p){
    d[x].f = cnt++;
    for (int j = 0; j < vi[x].size(); j++){
        int to = vi[x][j];
        if (to == p) continue;
        dfs(to,x);
    }
    d[x].s = cnt++;
}
 
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
    vector<int> labels;
    for (int i = 0; i < 1001; i++){
        vi[i].clear();
        d[i].f = 0;
        d[i].f = d[i].s;
    }
    for (int i = 0; i < u.size(); i++){
        vi[u[i]].pb(v[i]);
        vi[v[i]].pb(u[i]);
    }
    cnt = 0;
    dfs(0,0);
    for (int i = 0; i < n; i++)
        labels.pb((d[i].f) * 1000 + d[i].s);
    
    return labels;
}
int find_next_station(int s, int t, vector<int> v1) {
    if (s / 1000 < t / 1000){
        for (int i = 1; i < v1.size();i++)
            if (t / 1000 >= v1[i] / 1000 && v1[i] % 1000 >= t % 1000) return v1[i];
    }
    return v1[0];
}

Compilation message

stations.cpp: In function 'void dfs(int, int)':
stations.cpp:15:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for (int j = 0; j < vi[x].size(); j++){
      |                     ~~^~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:30:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for (int i = 0; i < u.size(); i++){
      |                     ~~^~~~~~~~~~
stations.cpp:31:18: error: 'class std::vector<int>' has no member named 'pb'
   31 |         vi[u[i]].pb(v[i]);
      |                  ^~
stations.cpp:32:18: error: 'class std::vector<int>' has no member named 'pb'
   32 |         vi[v[i]].pb(u[i]);
      |                  ^~
stations.cpp:37:16: error: 'class std::vector<int>' has no member named 'pb'
   37 |         labels.pb((d[i].f) * 1000 + d[i].s);
      |                ^~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:43:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for (int i = 1; i < v1.size();i++)
      |                         ~~^~~~~~~~~~~