Submission #989637

#TimeUsernameProblemLanguageResultExecution timeMemory
989637canadavid1Ancient Machine 2 (JOI23_ancient2)C++17
10 / 100
149 ms1556 KiB
#include "ancient2.h"

#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

namespace {

int variable_example = 1;

}  // namespace

std::string Solve(int N) {
  // query one bit:
  // a[i], b[i] = i+1
  // a[b] = 1000
  // b[b] = 1001
  // a,b[1001] = 1001
  // a,b[1000] = 1000
  std::vector<int> a(N+2);
  std::iota(a.begin(),a.begin()+N,1);
  a[N] = N;
  a[N+1] = N+1;
  auto b = a;
  std::string s;
  for(int i = 0; i < N; i++)
  {
    a[i] = N;
    b[i] = N+1;
    s.push_back((Query(N+2,a,b)>N) ? '1' : '0');
    a[i] = i+1;
    b[i] = i+1;
  }
  return s;
}

Compilation message (stderr)

ancient2.cpp:10:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
   10 | int variable_example = 1;
      |     ^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...