Submission #329706

# Submission time Handle Problem Language Result Execution time Memory
329706 2020-11-22T06:15:16 Z NintsiChkhaidze Stations (IOI20_stations) C++14
Compilation error
0 ms 0 KB
#include "stations.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
vector <int> vec[1005];
int cnt,in[1005],out[1005];
void dfs(int x,int p){
    in[x] = ++cnt;
    for (int j=0;j<vec[x].size();j++){
        int to = vec[x][j];
        if (to == p) continue;
        dfs(to,x);
    }
    out[x] = cnt;
}
 
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
    vector<int> labels;
    for (int i=0;i<1000;i++){
        vec[i].clear();
        in[i] = out[i] = 0;
    }
    for (int i=0;i<u.size();i++){
        vec[u[i]].pb(v[i]);
        vec[v[i]].pb(u[i]);
    }
    cnt=0;
    dfs(0,0);
    for (int i=0;i<n;i++)
        labels.pb(in[i]*1001 + out[i]);
    
    return labels;
}
int find_next_station(int s, int t, vector<int> c) {
    int Ins = s/1001,Outs = s%1001,Int = t/1001,Out = t%1001;
    if (Ins < Int){
        for (int i=0;i<c.size();i++){
            if (Int >= c[i]/1001 && c[i]%1001 >= Out) return x;
        }
    }
    else{
        for (int i=0;i<c.size();i++){
            if (Int <= c[i]/1001 && c[i]%1001 <= Out) return x;
        }
    }
}

Compilation message

stations.cpp: In function 'void dfs(int, int)':
stations.cpp:9:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for (int j=0;j<vec[x].size();j++){
      |                  ~^~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:23:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for (int i=0;i<u.size();i++){
      |                  ~^~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for (int i=0;i<c.size();i++){
      |                      ~^~~~~~~~~
stations.cpp:38:62: error: 'x' was not declared in this scope
   38 |             if (Int >= c[i]/1001 && c[i]%1001 >= Out) return x;
      |                                                              ^
stations.cpp:42:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         for (int i=0;i<c.size();i++){
      |                      ~^~~~~~~~~
stations.cpp:43:62: error: 'x' was not declared in this scope
   43 |             if (Int <= c[i]/1001 && c[i]%1001 <= Out) return x;
      |                                                              ^
stations.cpp:35:22: warning: unused variable 'Outs' [-Wunused-variable]
   35 |     int Ins = s/1001,Outs = s%1001,Int = t/1001,Out = t%1001;
      |                      ^~~~