Submission #420542

#TimeUsernameProblemLanguageResultExecution timeMemory
420542SSRSSplit the Attractions (IOI19_split)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; void dfs(vector<vector<int>> &E, vector<bool> &used, vector<int> &p, int v){ p.push_back(v); for (int w : E[v]){ if (!used[w]){ used[w] = true; dfs(E, used, p, w); } } } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q){ int m = p.size(); vector<vector<int>> E(n); for (int i = 0; i < m; i++){ E[p[i]].push_back(q[i]); E[q[i]].push_back(p[i]); } for (int i = 0; i < n; i++){ assert(E[i].size() == 2); } int s = 0; for (int i = 0; i < n; i++){ if (E[i].size() == 1){ s = i; } } vector<bool> used(n, false); vector<int> p; dfs(E, used, p, s); vector<int> ans(n); for (int i = 0; i < a; i++){ ans[p[i]] = 1; } for (int i = a; i < a + b; i++){ ans[p[i]] = 2; } for (int i = a + b; i < a + b + c; i++){ ans[p[i]] = 3; } return ans; }

Compilation message (stderr)

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:29:15: error: declaration of 'std::vector<int> p' shadows a parameter
   29 |   vector<int> p;
      |               ^
split.cpp:12:64: note: 'std::vector<int> p' previously declared here
   12 | vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q){
      |                                                    ~~~~~~~~~~~~^