Submission #1130910

#TimeUsernameProblemLanguageResultExecution timeMemory
1130910yellowtoadRailway (BOI17_railway)C++17
Compilation error
0 ms0 KiB
//testing

#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;

int main() {
    int n, m, k;
    cin >> n >> m >> k;

    vector<pair<int, int>> tracks(n - 1);
    unordered_map<pair<int, int>, int, boost::hash<pair<int, int>>> track_count;

    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        if (a > b) swap(a, b);
        tracks[i] = {a, b};
    }

    for (int i = 0; i < m; ++i) {
        int si;
        cin >> si;
        vector<int> neighborhoods(si);
        for (int j = 0; j < si; ++j) {
            cin >> neighborhoods[j];
        }

        for (int j = 0; j < si; ++j) {
            for (int l = j + 1; l < si; ++l) {
                int a = neighborhoods[j];
                int b = neighborhoods[l];
                if (a > b) swap(a, b);
                track_count[{a, b}]++;
            }
        }
    }

    vector<int> result;
    for (int i = 0; i < n - 1; ++i) {
        int a = tracks[i].first;
        int b = tracks[i].second;
        if (track_count[{a, b}] >= k) {
            result.push_back(i + 1);
        }
    }

    cout << result.size() << endl;
    for (int id : result) {
        cout << id << " ";
    }
    cout << endl;

    return 0;
}

Compilation message (stderr)

railway.cpp: In function 'int main()':
railway.cpp:15:40: error: 'boost' was not declared in this scope
   15 |     unordered_map<pair<int, int>, int, boost::hash<pair<int, int>>> track_count;
      |                                        ^~~~~
railway.cpp:15:67: error: template argument 3 is invalid
   15 |     unordered_map<pair<int, int>, int, boost::hash<pair<int, int>>> track_count;
      |                                                                   ^
railway.cpp:37:28: error: invalid types 'int[<brace-enclosed initializer list>]' for array subscript
   37 |                 track_count[{a, b}]++;
      |                            ^
railway.cpp:46:24: error: invalid types 'int[<brace-enclosed initializer list>]' for array subscript
   46 |         if (track_count[{a, b}] >= k) {
      |                        ^