제출 #994981

#제출 시각아이디문제언어결과실행 시간메모리
994981pera도서관 (JOI18_library)C++17
0 / 100
34 ms344 KiB
#include<bits/stdc++.h>
#include "library.h"
using namespace std;
void Solve(int N){
   vector<int> ans , e(N) , tx(N);
   for(int i = 0;i < N;i ++){
      tx[i] = e[i] = 1;
   }
   int L = -1;
   for(int i = 0;i < N;i ++){
      tx[i] = 0;
      if(Query(tx) == 1){
         L = i;
         break;
      }
      tx[i] = 1;
   }
   e[L] = 0;
   ans.push_back(L);
   for(int r = 1;r < N;r ++){
      int pos = 0;
      for(int bit = 10;bit >= 0;bit --){
         int _pos = pos + (1 << bit);
         if(_pos <= N - r){
            vector<int> u(N);
            for(int i = 0;i < N;i ++){
               if(_pos > 0 && e[i]){
                  --_pos;
                  u[i] = 1;
               }
            }
            int bef = Query(u);
            u[ans.back()] = 1;
            int now = Query(u);
            if(bef != now){
               pos += (1 << bit);
            }
         }
      }
      ++pos;
      for(int i = 0;i < N;i ++){
         if(e[i]){
            --pos;
         }
         if(pos == 0){
            pos = i;
            break;
         }
      }
      ans.push_back(pos);
      e[pos] = 0;
   }
   for(int i = 0;i < N;i ++){
      ++ans[i];
   }
   Answer(ans);
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...