Submission #444797

#TimeUsernameProblemLanguageResultExecution timeMemory
444797ics0503Chameleon's Love (JOI20_chameleon)C++17
100 / 100
49 ms360 KiB
#include "chameleon.h" #include <vector> #include<algorithm> using namespace std; int cck[1212]; int validation(int n, int i, int j) { vector<int>qr; for (int p = 1; p <= 2 * n; p++) { if (i == p || j == p)continue; qr.push_back(p); } int Q = Query(qr); if (Q != n) { cck[i] = cck[j] = 1; Answer(i, j); return 1; } return 0; } int S4(int who, vector<int>Y, int n) { int sz = Y.size(), i, j; if (sz == 1) { return validation(n, who, Y[0]); } vector<int>L, R; for (i = 0; i < sz / 2; i++)L.push_back(Y[i]); for (i = sz / 2; i < sz; i++)R.push_back(Y[i]); L.push_back(who); int a = Query(L); L.pop_back(); if (a != L.size() + 1) if (S4(who, L, n))return 1; R.push_back(who); int b = Query(R); R.pop_back(); if (b != R.size() + 1) if (S4(who, R, n))return 1; return 0; } vector<int>AX, AY; int pk[1212]; void Solve(int n) { int i, j; int qq = 0; while (1) { vector<int>X; qq++; for (i = 1; i <= 2 * n; i++)pk[i] = 0; int cnt = 0; for (i = 1; i <= 2 * n; i++) { if (cck[i])continue; cnt++; X.push_back(i); if (Query(X) != X.size()) X.pop_back(); else pk[i] = 1; } if (cnt == 0)break; X.clear(); for (i = 1; i <= 2 * n; i++) { if (cck[i])continue; cnt++; if (pk[i] == 1)continue; X.push_back(i); if (Query(X) != X.size()) X.pop_back(); else pk[i] = 2; } AX.clear(); AY.clear(); for (i = 1; i <= 2 * n; i++) { if (cck[i])continue; if (pk[i] == 2)AX.push_back(i); else AY.push_back(i); } for (i = 0; i < AX.size(); i++) { int who = AX[i]; vector<int>Y; for (j = 0; j < AY.size(); j++) { int v = AY[j]; if (cck[v])continue; Y.push_back(v); } S4(who, Y, n); } } }

Compilation message (stderr)

chameleon.cpp: In function 'int S4(int, std::vector<int>, int)':
chameleon.cpp:31:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  if (a != L.size() + 1) if (S4(who, L, n))return 1;
      |      ~~^~~~~~~~~~~~~~~
chameleon.cpp:33:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  if (b != R.size() + 1) if (S4(who, R, n))return 1;
      |      ~~^~~~~~~~~~~~~~~
chameleon.cpp:23:24: warning: unused variable 'j' [-Wunused-variable]
   23 |  int sz = Y.size(), i, j;
      |                        ^
chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:49:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   49 |    if (cck[i])continue; cnt++;
      |    ^~
chameleon.cpp:49:25: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   49 |    if (cck[i])continue; cnt++;
      |                         ^~~
chameleon.cpp:51:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |    if (Query(X) != X.size()) X.pop_back();
      |        ~~~~~~~~~^~~~~~~~~~~
chameleon.cpp:57:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   57 |    if (cck[i])continue; cnt++;
      |    ^~
chameleon.cpp:57:25: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   57 |    if (cck[i])continue; cnt++;
      |                         ^~~
chameleon.cpp:60:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |    if (Query(X) != X.size()) X.pop_back();
      |        ~~~~~~~~~^~~~~~~~~~~
chameleon.cpp:69:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |   for (i = 0; i < AX.size(); i++) {
      |               ~~^~~~~~~~~~~
chameleon.cpp:72:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |    for (j = 0; j < AY.size(); j++) {
      |                ~~^~~~~~~~~~~
#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...