Submission #832912

#TimeUsernameProblemLanguageResultExecution timeMemory
832912HorizonWestSplit the Attractions (IOI19_split)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; vector <vector<int>> v; int N; vector <int> g, p1, dp, ans, pass; vector <pair<int, int>> gx; int last(int node) { p1[node] = 1; for(auto& u : v[node]) if(!p1[node]) return last(u); return node; } void dfs(int node, int& cont, int& group) { ans[node] = group; cont++; if(cont == gx[group].fs) { cont = 0; group = max(1, (group + 1) % 4); } pass[node] = 1; for(auto& u : v[node]) { if(!pass[u]) { dfs(u, cont, group); } } return; } void dfs2(int node, int parent) { for(auto& u : v[node]) if(u != parent) { dfs2(u, node); dp[node] += dp[u]; } } void dfs3(int node, int parent, int& cont, int& group) { if(cont == gx[group].fs) return; cont++; ans[node] = gx[group].sd; for(auto& u : v[node]) if(u != parent) { dfs2(u, node, cont, group); } } void dfs4(int node, int parent) { for(auto& u : v[node]) if(u != parent) { if(dp[u] >= gx[0].fs && N - dp[u] >= gx[1].fs) { int cont = 0, group = 0; dfs3(u, node, 0, 0); cont = 0; group = 1; for(auto& j : v[node]) if(j != u) { dfs3(u, node, cont, group); } return; } if(dp[u] >= gx[0].fs && N - dp[u] >= gx[1].fs) { int cont = 0, group = 1; dfs3(u, node, cont, group); cont = 0; group = 0; for(auto& j : v[node]) if(j != u) { dfs3(u, node, cont, group); } return; } } } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { int m = p.size(); ans.assign(n, 3); pass.assign(n, 0); N = n; v.assign(n + 1, vector <int> ()); vector <bool> subtask(5, 1); for(int i = 0; i < m; i++) { v[p[i]].push_back(q[i]); v[q[i]].push_back(p[i]); if(v[p[i]].size() > 2) subtask[0] = false; if(v[q[i]].size() > 2) subtask[0] = false; } if(a != 1) subtask[1] = false; if(subtask[0] || subtask[1]) { p1.assign(n, 0); g.assign(4, 0); g[1] = a; g[2] = b; g[3] = c; int cont = 0, group = 2; dfs(last(0), cont, group); return ans; } if(subtask[2]) { gx = {{ a, 1 }, { b, 2 }, { c, 3 }}; ans.clear(); ans.assign(n, gx[2].fs); dp.assign(n, 1); dfs2(0, -1); sort(all(gx)); dfs4(0, -1); return ans; } return ans; }

Compilation message (stderr)

split.cpp: In function 'void dfs(int, int&, int&)':
split.cpp:19:26: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'fs'
   19 |     if(cont == gx[group].fs)
      |                          ^~
split.cpp: In function 'void dfs3(int, int, int&, int&)':
split.cpp:47:26: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'fs'
   47 |     if(cont == gx[group].fs) return;
      |                          ^~
split.cpp:48:35: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'sd'
   48 |     cont++; ans[node] = gx[group].sd;
      |                                   ^~
split.cpp:51:34: error: too many arguments to function 'void dfs2(int, int)'
   51 |         dfs2(u, node, cont, group);
      |                                  ^
split.cpp:36:6: note: declared here
   36 | void dfs2(int node, int parent)
      |      ^~~~
split.cpp: In function 'void dfs4(int, int)':
split.cpp:59:27: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'fs'
   59 |         if(dp[u] >= gx[0].fs && N - dp[u] >= gx[1].fs)
      |                           ^~
split.cpp:59:52: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'fs'
   59 |         if(dp[u] >= gx[0].fs && N - dp[u] >= gx[1].fs)
      |                                                    ^~
split.cpp:62:27: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
   62 |             dfs3(u, node, 0, 0);
      |                           ^
split.cpp:45:38: note:   initializing argument 3 of 'void dfs3(int, int, int&, int&)'
   45 | void dfs3(int node, int parent, int& cont, int& group)
      |                                 ~~~~~^~~~
split.cpp:71:27: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'fs'
   71 |         if(dp[u] >= gx[0].fs && N - dp[u] >= gx[1].fs)
      |                           ^~
split.cpp:71:52: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'fs'
   71 |         if(dp[u] >= gx[0].fs && N - dp[u] >= gx[1].fs)
      |                                                    ^~
split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:115:42: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'fs'
  115 |         ans.clear(); ans.assign(n, gx[2].fs);
      |                                          ^~
split.cpp:117:14: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
  117 |         sort(all(gx));
      |              ^~~
      |              std::filesystem::perms::all
In file included from /usr/include/c++/10/filesystem:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from split.cpp:1:
/usr/include/c++/10/bits/fs_fwd.h:148:7: note: 'std::filesystem::perms::all' declared here
  148 |       all  =  0777,
      |       ^~~