Submission #402038

# Submission time Handle Problem Language Result Execution time Memory
402038 2021-05-11T08:36:01 Z victoriad Library (JOI18_library) C++14
0 / 100
1 ms 328 KB
#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;
 
void Solve(int N)
{ 
  vector<int>res;
  
  if(N==1){
    res.push_back(1);
    Answer(res);
  }
  
  else{

    int primero;
    vector<int>l(N,1);
          for(int i=0;i<N;i++){
           l[i]--;
            if(Query(l)==1){
           primero=i+1;
           res[0]=primero;
            l[i]++;
            break;
            }
          l[i]++;
          }
          
  vector<bool>c(N,false);
  c[primero-1]=true;
  while(res.size()<N){
    vector<int>libres;
    for(int i=0;i<N;i++){
      if(!c[i])libres.push_back(i);
    }
    int low=0,hi=libres.size();
    l.assign(N,0);
    while(low<=hi){
      int mid=low+(hi-low)/2;
      for(int i=low;i<hi;i++)l[libres[i]]++;
      int v=Query(l);
      l[res[res.size()-1]]++;
      if(v==Query(l)){
        hi=mid;
      }
      else{
        low=mid+1;
      }
    }
    res.push_back(libres[low]+1);
    c[libres[low]]=true;
  }
  Answer(res);
  }
       
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:32:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |   while(res.size()<N){
      |         ~~~~~~~~~~^~
library.cpp:31:12: warning: 'primero' may be used uninitialized in this function [-Wmaybe-uninitialized]
   31 |   c[primero-1]=true;
      |     ~~~~~~~^~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 328 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 328 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -