Submission #541531

# Submission time Handle Problem Language Result Execution time Memory
541531 2022-03-23T18:02:41 Z fadi57 Library (JOI18_library) C++14
0 / 100
11 ms 304 KB
#include <cstdio>
#include <vector>
#include "library.h"
//#include "grader.cpp"
using namespace std;

void Solve(int n)
{
	if(n==1){
        vector<int>ans;
        ans={1};
       Answer (ans);
       return;
	}
  vector<int>q(n,1);int st=0;
  for(int i=0;i<n;i++){
        q[i]=0;
      int x=Query(q);
  q[i]=1;
  if(x==1){
    st=i;}
    }
    vector<int>ans;
    ans.push_back(st);
    vector<int>comp;
    for(int i=0;i<n;i++){
        if(i!=st){
            comp.push_back(i);
        }
    }
    while(comp.size()){
        int s=0;int en=comp.size()-1;
        while(s<=en){
            int mid=(s+en)/2;
            vector<int>Q(n,0);
            for(int j=0;j<mid;j++){
                Q[comp[j]]=1;

            }
            int x=Query(Q);
            Q[ans.back()]=1;
            int y=Query(Q);
            if(y==x){
                en=mid-1;
            }else{
             s=mid+1;
            }

        }
        ans.push_back(comp[s]);
          swap(comp[s], comp.back());
        comp.pop_back();


    }
    for(auto &it:ans){it++;

    }
    Answer(ans);

}
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 304 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 304 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -