Submission #537306

# Submission time Handle Problem Language Result Execution time Memory
537306 2022-03-14T23:44:49 Z smth Cave (IOI13_cave) C++14
0 / 100
2 ms 724 KB
#include "cave.h"
#include<vector>
#include<iostream>
using namespace std;

int s[100000], doors[100000];

void exploreCave(int N) {

   vector<long long>v(N);
   long long i,j;
   for(i=0;i<N;i++){s[i]=doors[i]=0; v[i]=i;}


   bool sit;

       for(i=0;i<N;i++)
       {
           for(j=0;j<v.size();j++)s[v[j]]=0;

           if(tryCombination(s))sit=0;
           else sit=1;

           long long le=0, ri=v.size()-1, mid;

           while(le<=ri)
           {
               mid=(le+ri)/2;

               for(int k=0;k<v.size();k++)
               {
                   if(k<i)s[v[k]]=sit;
                   else s[v[i]]=!sit;
               }

               if(tryCombination(s)==i)ri=mid-1;
               else le=mid+1;
           }

           s[v[le]]=!sit;
           doors[v[le]]=i;

           v.erase(v.begin()+le);
       }
       answer(s,doors);
}

Compilation message

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:19:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |            for(j=0;j<v.size();j++)s[v[j]]=0;
      |                    ~^~~~~~~~~
cave.cpp:30:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |                for(int k=0;k<v.size();k++)
      |                            ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -