Submission #699454

# Submission time Handle Problem Language Result Execution time Memory
699454 2023-02-17T03:14:21 Z null_awe Library (JOI18_library) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#include "library.h"
using namespace std;

void Solve(int n) {
  vector<int> front;
  vector<int> back;
  vector<int> left; for (int i = 0; i < n; ++i) left.push_back(i);
  while (left.size()) {
    int l = 0, r = left.size();
    while (l < r - 1) {
      int mid = (l + r) >> 1;
      vector<int> first(n), second(n);
      for (int i = 0; i < left.size(); ++i) {
        if (i >= l && i < mid) first[left[i]] = 1;
        else second[left[i]] = 1;
      }
      int q1 = Query(first), q2 = Query(second);
      if (q1 >= q2) r = mid;
      else l = mid;
    }
    int ind = 0;
    for (int i = 0; i < left.size(); ++i) if (left[i] == l) ind = i;
    left.erase(left.begin() + ind);
    vector<int> arr(n);
    arr[front.back()] = 1, arr[l] = 1;
    int q = Query(arr);
    if (q == 1) front.push_back(l);
    else back.push_back(l);
  }
  vector<int> ans;
  for (int num : front) ans.push_back(num + 1);
  reverse(back.begin(), back.end());
  for (int num : back) ans.push_back(num + 1);
  Answer(ans);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:15:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |       for (int i = 0; i < left.size(); ++i) {
      |                       ~~^~~~~~~~~~~~~
library.cpp:24:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for (int i = 0; i < left.size(); ++i) if (left[i] == l) ind = i;
      |                     ~~^~~~~~~~~~~~~
library.cpp:34:3: error: 'reverse' was not declared in this scope
   34 |   reverse(back.begin(), back.end());
      |   ^~~~~~~