Submission #466437

#TimeUsernameProblemLanguageResultExecution timeMemory
466437prvocisloChameleon's Love (JOI20_chameleon)C++17
Compilation error
0 ms0 KiB
#include "chameleon.h" #include <vector> #include <iostream> using namespace std; const int maxn = 505; vector<int> g[maxn * 2]; vector<pair<int, int>> v; bool vis[maxn]; int query(int x, vector<int> a) { a.push_back(x); return Query(a); } void find_edges(int x, const vector<int> &a) { if (!a.size()) return; if (a.size() == 1) { //cout << x << " " << a[0] << "\n"; if (query(x, a) == 1) g[x].push_back(a[0]), g[a[0]].push_back(x); return; } vector<int> a1(a.begin(), a.begin() + a.size() / 2), a2(a.begin() + a.size() / 2, a.end()); int c1 = query(x, a1), c2 = query(x, a2); if (c1 < a1.size() + 1) find_edges(x, a1); if (c2 < a2.size() + 1) find_edges(x, a2); } void dfs(int u, int c, vector<vector<int> >& k) { k[c].push_back(u), vis[u] = true; for (int v : g[u]) if (!vis[v]) dfs(v, c ^ 1, k); } void Solve(int n) { for (int i = 2; i <= 2 * n; i++) { vector<vector<int> > k(2); fill(vis, vis + maxn, false); for (int j = 1; j < i; j++) if (!vis[j]) dfs(j, 0, k); find_edges(i, k[0]); find_edges(i, k[1]); } for (int i = 1; i <= 2 * n; i++) if (g[i].size() == 3) { for (int j = 0; j < 3; j++) for (int k = 0; k < j; k++) { int c = query(i, { g[i][j], g[i][k] }); if (c == 1) v.push_back({ i, g[i][3 ^ j ^ k] }); } } for (const pair<int, int>& i : v) { g[i.first].erase(find(g[i.first].begin(), g[i.first].end(), i.second)); g[i.second].erase(find(g[i.second].begin(), g[i.second].end(), i.first)); } for (int i = 1; i <= 2 * n; i++) if (g[i][0] > i) { Answer(i, g[i][0]); } }

Compilation message (stderr)

chameleon.cpp: In function 'void find_edges(int, const std::vector<int>&)':
chameleon.cpp:26:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |  if (c1 < a1.size() + 1) find_edges(x, a1);
      |      ~~~^~~~~~~~~~~~~~~
chameleon.cpp:27:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  if (c2 < a2.size() + 1) find_edges(x, a2);
      |      ~~~^~~~~~~~~~~~~~~
chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:54:71: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, const int&)'
   54 |   g[i.first].erase(find(g[i.first].begin(), g[i.first].end(), i.second));
      |                                                                       ^
In file included from /usr/include/c++/10/bits/locale_facets.h:48,
                 from /usr/include/c++/10/bits/basic_ios.h:37,
                 from /usr/include/c++/10/ios:44,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from chameleon.cpp:3:
/usr/include/c++/10/bits/streambuf_iterator.h:422:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(std::istreambuf_iterator<_CharT>, std::istreambuf_iterator<_CharT>, const _CharT2&)'
  422 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/10/bits/streambuf_iterator.h:422:5: note:   template argument deduction/substitution failed:
chameleon.cpp:54:71: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   54 |   g[i.first].erase(find(g[i.first].begin(), g[i.first].end(), i.second));
      |                                                                       ^
chameleon.cpp:55:73: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, const int&)'
   55 |   g[i.second].erase(find(g[i.second].begin(), g[i.second].end(), i.first));
      |                                                                         ^
In file included from /usr/include/c++/10/bits/locale_facets.h:48,
                 from /usr/include/c++/10/bits/basic_ios.h:37,
                 from /usr/include/c++/10/ios:44,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from chameleon.cpp:3:
/usr/include/c++/10/bits/streambuf_iterator.h:422:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(std::istreambuf_iterator<_CharT>, std::istreambuf_iterator<_CharT>, const _CharT2&)'
  422 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/10/bits/streambuf_iterator.h:422:5: note:   template argument deduction/substitution failed:
chameleon.cpp:55:73: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   55 |   g[i.second].erase(find(g[i.second].begin(), g[i.second].end(), i.first));
      |                                                                         ^