Submission #333457

# Submission time Handle Problem Language Result Execution time Memory
333457 2020-12-06T05:56:42 Z sabamaku Stations (IOI20_stations) C++14
Compilation error
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:11:1: error: expected initializer before 'vector'
   11 | vector <int> vi[2005];
      | ^~~~~~
stations.cpp: In function 'void dfs(int, int)':
stations.cpp:14:5: error: 'd' was not declared in this scope
   14 |     d[x].f = cnt++;
      |     ^
stations.cpp:15:25: error: 'vi' was not declared in this scope
   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:26:9: error: 'vi' was not declared in this scope; did you mean 'i'?
   26 |         vi[i].clear();
      |         ^~
      |         i
stations.cpp:27:9: error: 'd' was not declared in this scope
   27 |         d[i].f = 0;
      |         ^
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:9: error: 'vi' was not declared in this scope; did you mean 'i'?
   31 |         vi[u[i]].pb(v[i]);
      |         ^~
      |         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:37:20: error: 'd' was not declared in this scope
   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++)
      |                         ~~^~~~~~~~~~~