Submission #810967

#TimeUsernameProblemLanguageResultExecution timeMemory
810967taherAncient Machine 2 (JOI23_ancient2)C++17
10 / 100
182 ms540 KiB
#include "ancient2.h"
 
#include <bits/stdc++.h>
 
using namespace std;
 
string Solve(int N) {
  string s;
 
  const int M = 1002;
  vector<int> a(M);
  vector<int> b(M);
  a[0] = 1;
  a[1] = 1;
  b[1] = 1;
 
  b[0] = 2;
  b[2] = 2;
  a[2] = 2;
 
  for (int i = 0; i < N - 1; i++) {
    int ret = Query(M, a, b);
 
    if (ret == i + 1) {
      s += '0';
      a[i] = i + 1;
    } else {
      s += '1';
      b[i] = i + 1;
    }
 
    a[i + 1] = i + 2;
    a[i + 2] = i + 2;
    b[i + 2] = i + 2;
 
    b[i + 1] = i + 3;
    b[i + 3] = i + 3;
    a[i + 3] = i + 3;
  }

  a.assign(M, 0);
  b.assign(M, 1);
  int ret = Query(M, a, b);
  s += (ret + '0');
  return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...