Submission #891448

#TimeUsernameProblemLanguageResultExecution timeMemory
891448Jawad_Akbar_JJSplit the Attractions (IOI19_split)C++17
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <cstdio> #include <cassert> #include <algorithm> #include "split.h" using namespace std; const int N = (1<<18) + 1; vector<int> nei[N],ch[N]; int color[N],A,B; int sz[N],blocked = -1; bool seen[N],found = false; void color_it(int u,int c){ color[u] = c; A--; if (A == 0) return; for (int i : ch[u]){ if (blocked == i) continue; color_it(i,c); if (A==0) return; } } void dfs(int u){ seen[u] = true; sz[u] = 1; for (int i : nei[u]){ if (seen[i]) continue; ch[u].push_back(i); dfs(i); sz[u] += sz[i]; } } void dfs2(int u){ for (int i : ch[u]){ if (found) return; if (sz[i]>=A and (sz[1] - sz[i]) >= B){ color_it(i,1); A = B; blocked = i; color_it(1,2); found = true; return; } dfs2(i); } } vector<int> find_split(int n,int a,int b,int c,vector<int> p,vector<int> q){ int m = p.size(); for (int i=0;i<m;i++){ p[i]++; q[i]++; nei[p[i]].push_back(q[i]); nei[q[i]].push_back(p[i]); } dfs(1); vector<int> vv = {a,b,c}; sort(begin(vv),end(vv)); if (a==vv[0] and b==vv[1]) A = a,B = b; if (a==v[0] and c==vv[1]) A = a,B = c; if (c==vv[0] and b==vv[1]) A = c,B = b; if (c==v[0] and a==vv[1]) A = c,B = a; if (b==vv[0] and c==vv[1]) A = b,B = c; if (b==v[0] and a==vv[1]) A = b,B = a; dfs2(1); vector<int> ans; for (int i=1;i<=n;i++){ if (found and color[i]==0) ans.push_back(3); else ans.push_back(color[i]); } return ans; } // int main() { // int n, m, a, b, c; // assert(5 == scanf("%d%d%d%d%d", &n, &m, &a, &b, &c)); // vector<int> p(m), q(m); // for (int i=0; i<m; i++) // assert(2 == scanf("%d%d", &p[i], &q[i])); // fclose(stdin); // vector<int> result = find_split(n, a, b, c, p, q); // for (int i=0; i<(int)result.size(); i++) // printf("%s%d", ((i>0)?" ":""), result[i]); // printf("\n"); // fclose(stdout); // return 0; // }

Compilation message (stderr)

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:79:9: error: 'v' was not declared in this scope; did you mean 'vv'?
   79 |  if (a==v[0] and c==vv[1])
      |         ^
      |         vv
split.cpp:83:9: error: 'v' was not declared in this scope; did you mean 'vv'?
   83 |  if (c==v[0] and a==vv[1])
      |         ^
      |         vv
split.cpp:87:9: error: 'v' was not declared in this scope; did you mean 'vv'?
   87 |  if (b==v[0] and a==vv[1])
      |         ^
      |         vv