Submission #466439

#TimeUsernameProblemLanguageResultExecution timeMemory
466439prvocisloChameleon's Love (JOI20_chameleon)C++17
40 / 100
32 ms668 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 * 2]; 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 rmv(int a, int b) { for (int i = 0; i < g[a].size(); i++) if (g[a][i] == b) { g[a].erase(g[a].begin() + i); break; } } 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) { rmv(i.first, i.second); rmv(i.second, 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 rmv(int, int)':
chameleon.cpp:36:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  for (int i = 0; i < g[a].size(); i++) if (g[a][i] == b)
      |                  ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...