Submission #786252

#TimeUsernameProblemLanguageResultExecution timeMemory
786252restingSplit the Attractions (IOI19_split)C++17
Compilation error
0 ms0 KiB
#include "split.h" #include <bits/stdc++.h> using namespace std; vector<int> ss, sz, pp, tin, low, st, res; int time = 1; vector<vector<int>> scc; void dfs(int v, int p) { low[v] = tin[v] = time++; pp[v] = p; st.push_back(v); for (auto& x : adj[v]) { if (tin[x]) low[v] = min(low[v], tin[x]); else { dfs(x, v); if (low[x] == v) { scc.push_back({}); while (st.back() != v) { scc.back().push_back(st.back()); st.pop_back(); } scc.push_back(v); } } } } int dfs_fill(int v, int t, int amt) { if (!amt || res[v]) return; res[v] = t; amt--; for (auto& x : adj[v]) amt = dfs_fill(v, t, amt); return amt; } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { int na = 1, nb = 2, nc = 3; if (a > b) { swap(a, b); swap(na, nb); } if (b > c) { swap(b, c); swap(nb, nc); } if (a > b) { swap(a, b); swap(nb, nc);//haha o(n) sorting OwO } sz = pp = tin = low = ss = res = vector<int>(n, 0); int m = p.size(); for (int i = 0; i < m; i++) { adj[p[i]].push_back(q[i]); adj[q[i]].push_back(p[i]); } dfs(0, 0); int mxv = 0, mxi = 0; for (int i = 0; i < scc.size(); i++) { int mxsz = 0; for (auto& x : scc[i]) { mxsz = max(mxsz, sz[x]); ss[x] = 0; } for (auto& x : scc[i]) { ss[x] += sz[x]; ss[pp[x]] -= sz[x]; if (sz[x] == mxsz) ss[x] += n - sz[x]; } for (auto& x : scc[i]) { if (sz[x] >= n / 3) { if (n - x > mxv) { mxv = n - x; mxi = i; goto end; } } } mxv = n / 3;mxi = i; end:; } if (mxv < a) return res; vector<int> mark1(n, 0); int mxsz = 0; for (auto& x : scc[mxi]) { mark1[x] = 1; mxsz = max(mxsz, sz[x]); ss[x] = 0; } for (auto& x : scc[i]) { ss[x] += sz[x]; ss[pp[x]] -= sz[x]; if (sz[x] == mxsz) ss[x] += n - sz[x]; } for (auto& x : scc[i]) { if (sz[x] >= n / 3) { res[x] = na; a--; for (auto& x : adj[x]) if (!mark1[x]) a = dfs_fill(x, na, a); for (auto& x : scc[i]) if (!res[x]) b = dfs_fill(x, nb, b); goto end; } } end:; for (auto& x : res)if (!x)x = nc; return res; }

Compilation message (stderr)

split.cpp:6:48: error: 'int time' redeclared as different kind of entity
    6 | vector<int> ss, sz, pp, tin, low, st, res; int time = 1;
      |                                                ^~~~
In file included from /usr/include/c++/10/ctime:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:49,
                 from split.cpp:2:
/usr/include/time.h:75:15: note: previous declaration 'time_t time(time_t*)'
   75 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
split.cpp: In function 'void dfs(int, int)':
split.cpp:10:23: warning: ISO C++ forbids incrementing a pointer of type 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} [-Wpointer-arith]
   10 |     low[v] = tin[v] = time++; pp[v] = p;
      |                       ^~~~
split.cpp:10:23: error: lvalue required as increment operand
split.cpp:12:20: error: 'adj' was not declared in this scope
   12 |     for (auto& x : adj[v]) {
      |                    ^~~
split.cpp:19:32: error: no matching function for call to 'std::vector<std::vector<int> >::push_back(int&)'
   19 |                 scc.push_back(v);
      |                                ^
In file included from /usr/include/c++/10/vector:67,
                 from split.h:5,
                 from split.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::value_type = std::vector<int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'int' to 'const value_type&' {aka 'const std::vector<int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::value_type = std::vector<int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'int' to 'std::vector<std::vector<int> >::value_type&&' {aka 'std::vector<int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
split.cpp: In function 'int dfs_fill(int, int, int)':
split.cpp:26:25: error: return-statement with no value, in function returning 'int' [-fpermissive]
   26 |     if (!amt || res[v]) return;
      |                         ^~~~~~
split.cpp:28:20: error: 'adj' was not declared in this scope
   28 |     for (auto& x : adj[v]) amt = dfs_fill(v, t, amt);
      |                    ^~~
split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:50:9: error: 'adj' was not declared in this scope
   50 |         adj[p[i]].push_back(q[i]);
      |         ^~~
split.cpp:57:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for (int i = 0; i < scc.size(); i++) {
      |                     ~~^~~~~~~~~~~~
split.cpp:89:24: error: 'i' was not declared in this scope
   89 |     for (auto& x : scc[i]) {
      |                        ^
split.cpp:93:24: error: 'i' was not declared in this scope
   93 |     for (auto& x : scc[i]) {
      |                        ^
split.cpp:96:28: error: 'adj' was not declared in this scope
   96 |             for (auto& x : adj[x])
      |                            ^~~
split.cpp:76:5: error: jump to label 'end' [-fpermissive]
   76 |     end:;
      |     ^~~
split.cpp:102:18: note:   from here
  102 |             goto end;
      |                  ^~~
split.cpp:58:13: note:   skips initialization of 'int mxsz'
   58 |         int mxsz = 0;
      |             ^~~~
split.cpp:57:14: note:   skips initialization of 'int i'
   57 |     for (int i = 0; i < scc.size(); i++) {
      |              ^
split.cpp:107:1: error: duplicate label 'end'
  107 | end:;
      | ^~~