Submission #540738

#TimeUsernameProblemLanguageResultExecution timeMemory
540738two_sidesChameleon's Love (JOI20_chameleon)C++17
Compilation error
0 ms0 KiB
#include "chameleon.h" #include <bits/stdc++.h> using namespace std; bool check(vector<int> v, int x) { if (v.empty()) return false; v.push_back(x); return Query(v) != v.size(); } void Solve(int n) { n = n * 2 + 1; vector<vector<int>> adj(n + 1); vector<int> col(n + 1), ans(n + 1); vector<int> pre(n + 1), nxt(n + 1); queue<int> que; for (int i = 1; i <= n; i++) { for (int j = 1; j < i; j++) col[j] = -1; for (int j = 1, u; j < i; j++) { if (col[j] >= 0) continue; que.push(j); col[j] = 0; while (que.size()) { u = que.front(); que.pop(); for (int v : adj[u]) if (col[v] < 0) { col[v] = 1 - col[u]; que.push(v); } } } vector<int> half[2]; for (int j = 1; j < i; j++) half[col[j]].push_back(j); for (int j = 0; j < 2; j++) { while (check(half[j], i)) { int l = 1, r = half[j].size(); while (l < r) { int m = (l + r) / 2; if (check(vector<int> (half[j].begin(), half[j].begin() + m), i)) r = m; else l = m + 1; } adj[i].push_back(half[j][l - 1]); adj[half[j][l - 1]].push_back(i); half[j].erase(half[j].begin, half[j].begin() + l); } } } for (int i = 1; i <= n; i++) { if (adj[i].size() == 1) continue; while (Query({i, adj[i][0], adj[i][1]}) != 1) rotate(adj[i].begin(), adj[i].begin() + 1, adj[i].end()); nxt[i] = adj[i][2]; pre[adj[i][2]] = i; } for (int i = 1; i <= n; i++) { if (adj[i].size() == 1) ans[i] = adj[i][0]; else ans[i] = adj[i][0] + adj[i][1] + adj[i][2] - nxt[i] - pre[i]; if (ans[i] > i) Answer(i, ans[i]); } }

Compilation message (stderr)

chameleon.cpp: In function 'bool check(std::vector<int>, int)':
chameleon.cpp:9:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     return Query(v) != v.size();
      |            ~~~~~~~~~^~~~~~~~~~~
chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:50:36: error: no matching function for call to 'std::vector<int>::erase(<unresolved overloaded function type>, __gnu_cxx::__normal_iterator<int*, std::vector<int> >)'
   50 |                 half[j].begin() + l);
      |                                    ^
In file included from /usr/include/c++/10/vector:67,
                 from chameleon.h:5,
                 from chameleon.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1430:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator]'
 1430 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/10/bits/stl_vector.h:1430:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_vector.h:1457:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator]'
 1457 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/10/bits/stl_vector.h:1457:28: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::vector<int>::const_iterator'
 1457 |       erase(const_iterator __first, const_iterator __last)
      |             ~~~~~~~~~~~~~~~^~~~~~~