Submission #1031834

#TimeUsernameProblemLanguageResultExecution timeMemory
1031834aymanrsChameleon's Love (JOI20_chameleon)C++14
4 / 100
8 ms460 KiB
#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;
void Solve(int N) {
  bool v[2*N+1] = {false};
  int p = 1;
  vector<int> s = {1};
  for(int i = 2;i <= 2*N;i++){
    s.push_back(i);
    if(Query(s) > p){
      p++;
      continue;
    }
    p--;
    int l = 0, r = s.size()-2, m, b = -1;
    while(l<r){
      m = l+r>>1;
      swap(s[m+1], s.back());
      if(Query(vector<int>(s.begin()+l, s.begin()+m+2)) == m-l+2) l = m+1;
      else r=m;
      swap(s[m+1], s.back());
    }
    Answer(i, s[l]);
    s.pop_back();
    s.erase(s.begin()+l);
  }
}

Compilation message (stderr)

chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:17:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   17 |       m = l+r>>1;
      |           ~^~
chameleon.cpp:15:35: warning: unused variable 'b' [-Wunused-variable]
   15 |     int l = 0, r = s.size()-2, m, b = -1;
      |                                   ^
chameleon.cpp:5:8: warning: unused variable 'v' [-Wunused-variable]
    5 |   bool v[2*N+1] = {false};
      |        ^
#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...