답안 #699459

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
699459 2023-02-17T03:19:42 Z null_awe 도서관 (JOI18_library) C++14
100 / 100
425 ms 308 KB
#include <bits/stdc++.h>
#include "library.h"
using namespace std;

void Solve(int n) {
  vector<int> front, back, 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 val = left[l], ind = 0;
    for (int i = 0; i < left.size(); ++i) if (left[i] == val) ind = i;
    left.erase(left.begin() + ind);
    if (front.size()) {
      vector<int> arr(n);
      arr[front.back()] = 1, arr[val] = 1;
      int q = Query(arr);
      if (q == 1) front.push_back(val);
      else back.push_back(val);
    } else front.push_back(val);
  }
  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:13:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |       for (int i = 0; i < left.size(); ++i) {
      |                       ~~^~~~~~~~~~~~~
library.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (int i = 0; i < left.size(); ++i) if (left[i] == val) ind = i;
      |                     ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 284 KB # of queries: 2581
2 Correct 33 ms 284 KB # of queries: 2564
3 Correct 37 ms 284 KB # of queries: 2677
4 Correct 41 ms 208 KB # of queries: 2707
5 Correct 43 ms 284 KB # of queries: 2703
6 Correct 34 ms 288 KB # of queries: 2697
7 Correct 34 ms 280 KB # of queries: 2723
8 Correct 37 ms 208 KB # of queries: 2580
9 Correct 26 ms 284 KB # of queries: 2678
10 Correct 19 ms 208 KB # of queries: 1572
11 Correct 0 ms 208 KB # of queries: 0
12 Correct 0 ms 208 KB # of queries: 3
13 Correct 0 ms 208 KB # of queries: 8
14 Correct 1 ms 208 KB # of queries: 13
15 Correct 2 ms 208 KB # of queries: 92
16 Correct 3 ms 208 KB # of queries: 212
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 284 KB # of queries: 2581
2 Correct 33 ms 284 KB # of queries: 2564
3 Correct 37 ms 284 KB # of queries: 2677
4 Correct 41 ms 208 KB # of queries: 2707
5 Correct 43 ms 284 KB # of queries: 2703
6 Correct 34 ms 288 KB # of queries: 2697
7 Correct 34 ms 280 KB # of queries: 2723
8 Correct 37 ms 208 KB # of queries: 2580
9 Correct 26 ms 284 KB # of queries: 2678
10 Correct 19 ms 208 KB # of queries: 1572
11 Correct 0 ms 208 KB # of queries: 0
12 Correct 0 ms 208 KB # of queries: 3
13 Correct 0 ms 208 KB # of queries: 8
14 Correct 1 ms 208 KB # of queries: 13
15 Correct 2 ms 208 KB # of queries: 92
16 Correct 3 ms 208 KB # of queries: 212
17 Correct 380 ms 296 KB # of queries: 18153
18 Correct 414 ms 296 KB # of queries: 17978
19 Correct 393 ms 296 KB # of queries: 18101
20 Correct 407 ms 296 KB # of queries: 16945
21 Correct 366 ms 296 KB # of queries: 15944
22 Correct 417 ms 308 KB # of queries: 18173
23 Correct 399 ms 300 KB # of queries: 18108
24 Correct 142 ms 296 KB # of queries: 8334
25 Correct 395 ms 296 KB # of queries: 17744
26 Correct 417 ms 304 KB # of queries: 16508
27 Correct 152 ms 208 KB # of queries: 8282
28 Correct 424 ms 296 KB # of queries: 16973
29 Correct 425 ms 296 KB # of queries: 16954
30 Correct 425 ms 208 KB # of queries: 16973