Submission #1311166

#TimeUsernameProblemLanguageResultExecution timeMemory
1311166ayathkStations (IOI20_stations)C++20
Compilation error
0 ms0 KiB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define fi first 
#define se second
#define all(a) a.begin(), a.end()

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	vector<int> labels(n);
    vector <vector <int>> adj(n);
	for (int i = 0; i < n - 1; i++) {
        adj[u[i]].push_back(v[i]);
        adj[v[i]].push_back(u[i]);
	}

    queue <int> t;
    for(int i = 0;i < n;i++){
        if(adj[i].size() == 1){
            t.push(i);
            break;
        }
    }

    int cnt = 0;
    vector <bool> vis(n,0);
    while(!t.empty()){
        int f = t.front();
        t.pop();
        vis[f] = 1;
        labels[f] = cnt;
        for(int i : adj[f]){
            if(vis[i])continue;
            t.push(i);
        }
        cnt++;
    }

	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
    if(c.size() == 1)return c[0];
    pair <int> mn = (1e9,1e9);
    for(int i : c){
        if(mn.se > abs(i - t)){
            mn = {i, abs(i - t)};
        }
    }
    return mn.fi;
}

/*signed main(){
    vector <int> a = label(5, 8 ,{4,1,2,3,0}, {0,4,0,2,2});
    for(int i : a){
        cout<<i<<' ';
    }
}*/

Compilation message (stderr)

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:44:14: error: wrong number of template arguments (1, should be 2)
   44 |     pair <int> mn = (1e9,1e9);
      |              ^
In file included from /usr/include/c++/13/bits/stl_algobase.h:64,
                 from /usr/include/c++/13/vector:62,
                 from stations.h:1,
                 from stations.cpp:1:
/usr/include/c++/13/bits/stl_pair.h:187:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
  187 |     struct pair
      |            ^~~~
stations.cpp:6:12: error: request for member 'second' in 'mn', which is of non-class type 'int'
    6 | #define se second
      |            ^~~~~~
stations.cpp:46:15: note: in expansion of macro 'se'
   46 |         if(mn.se > abs(i - t)){
      |               ^~
stations.cpp:47:32: error: cannot convert '<brace-enclosed initializer list>' to 'int' in assignment
   47 |             mn = {i, abs(i - t)};
      |                                ^
stations.cpp:5:12: error: request for member 'first' in 'mn', which is of non-class type 'int'
    5 | #define fi first
      |            ^~~~~
stations.cpp:50:15: note: in expansion of macro 'fi'
   50 |     return mn.fi;
      |               ^~