Submission #521515

# Submission time Handle Problem Language Result Execution time Memory
521515 2022-02-02T10:09:57 Z cig32 Library (JOI18_library) C++17
0 / 100
40 ms 284 KB
#include "bits/stdc++.h"
using namespace std;
#include "library.h"
void Solve(int N)
{
  vector<int> M(N);
  for(int i=0; i<N; i++) M[i] = 1;
  vector<int> res(N);
  bool done[N+1];
  for(int i=0; i<N; i++) done[i] = 0;
  for(int i=0; i<N; i++) {
    M[i] = 0;
    int A = Query(M);
    if(A == 1) {
      res[0] = i + 1;
      done[i] = 1;
      break;
    }
    M[i] = 1;
  }
  for(int i=1; i<N; i++) {
    vector<int> v;
    for(int j=0; j<N; j++) {
      if(!done[j]) v.push_back(j);
    }
    int lb = 0, rb = v.size() - 1;
    while(lb < rb) {
      int mid = (lb + rb) >> 1;
      for(int j=0; j<N; j++) {
        if(done[j]) M[j] = 1;
        else M[j] = 0;
      }
      for(int j=0; j<=mid; j++) {
        M[v[j]] = 1;
      }
      int a1 = Query(M);
      for(int j=0; j<N; j++) {
        if(done[j]) M[j] = 0;
      }
      int a2 = Query(M);
      if(a1 == a2) rb = mid;
      else lb = mid + 1;
    }
    res[i] = v[lb] + 1;
    done[v[lb]] = 1;
  }
  Answer(res);
}
# Verdict Execution time Memory Grader output
1 Correct 34 ms 284 KB # of queries: 2387
2 Correct 33 ms 200 KB # of queries: 2433
3 Correct 35 ms 272 KB # of queries: 2638
4 Correct 28 ms 200 KB # of queries: 2593
5 Correct 34 ms 200 KB # of queries: 2504
6 Correct 29 ms 200 KB # of queries: 2553
7 Correct 40 ms 200 KB # of queries: 2568
8 Correct 35 ms 200 KB # of queries: 2402
9 Correct 33 ms 200 KB # of queries: 2512
10 Correct 22 ms 200 KB # of queries: 1478
11 Runtime error 0 ms 200 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 34 ms 284 KB # of queries: 2387
2 Correct 33 ms 200 KB # of queries: 2433
3 Correct 35 ms 272 KB # of queries: 2638
4 Correct 28 ms 200 KB # of queries: 2593
5 Correct 34 ms 200 KB # of queries: 2504
6 Correct 29 ms 200 KB # of queries: 2553
7 Correct 40 ms 200 KB # of queries: 2568
8 Correct 35 ms 200 KB # of queries: 2402
9 Correct 33 ms 200 KB # of queries: 2512
10 Correct 22 ms 200 KB # of queries: 1478
11 Runtime error 0 ms 200 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -