답안 #699455

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
699455 2023-02-17T03:14:38 Z null_awe 도서관 (JOI18_library) C++14
0 / 100
1 ms 432 KB
#include <iostream>
#include <vector>
#include <algorithm>
#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:16:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |       for (int i = 0; i < left.size(); ++i) {
      |                       ~~^~~~~~~~~~~~~
library.cpp:25:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for (int i = 0; i < left.size(); ++i) if (left[i] == l) ind = i;
      |                     ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 432 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 432 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -