Submission #1341448

#TimeUsernameProblemLanguageResultExecution timeMemory
1341448jumpCave (IOI13_cave)C++20
Compilation error
0 ms0 KiB
#include "cave.h"
#include <bits/stdc++.h>

bool found[5050];
int ans[5010];
int door[5050];
int test[5050];
std::vector<std::pair<int,int>> answer;
void exploreCave(int N) {
    int remain = N;
    int half = N/2;
    for(int i=0;i<=N;i++)found[i]=false,ans[i]=-1,door[i]=-1;
    while(remain>0){
        for(int i=0;i<=N;i++)test[i]=0;
        for(auto [idx,as]:answer)test[idx]=as;
        int curr=0;
        int i=0;
        std::vector<int> tested;
        int oResult = tryCombination(test);
        while(curr<half&&i<=N){
            if(!found[curr]){
                test[i]=1;
                tested.push_back(i);
                curr++;
            }
            i++;
        }
        int result = tryCombination(test);
        int l=0,r=tested.size()-1;
        int fidx = 0;
        while(l<r){
            int mid = (l+r+1)/2;
            for(int i=mid;i<=r;i++){
                test[tested[i]]=0;
            }
            int newresult = tryCombination(test);
            if((result<oResult&&newresult==result)||(result>oResult&&newresult<result)){
                r=mid-1;
                fidx=r;
            }
            else{
                l=mid;
                fidx=l;
            }
            for(int i=mid;i<=r;i++){
                test[tested[i]]=1;
            }
        }
        if(result<oResult){
            ans[tested[fidx]]=0;
            door[tested[fidx]]=result;
            found[tested[fidx]]=true;
        }
        else{
            ans[tested[fidx]]=1;
            door[tested[fidx]]=oResult;
            found[tested[fidx]]=true;
        }
    }
    answer(ans,door);
}

Compilation message (stderr)

cave.cpp:8:33: error: 'std::vector<std::pair<int, int> > answer' redeclared as different kind of entity
    8 | std::vector<std::pair<int,int>> answer;
      |                                 ^~~~~~
In file included from cave.cpp:1:
cave.h:9:6: note: previous declaration 'void answer(int*, int*)'
    9 | void answer(int S[], int D[]);
      |      ^~~~~~
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:15:27: error: 'begin' was not declared in this scope
   15 |         for(auto [idx,as]:answer)test[idx]=as;
      |                           ^~~~~~
cave.cpp:15:27: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:166,
                 from cave.cpp:2:
/usr/include/c++/13/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/13/bits/ranges_algobase.h:38,
                 from /usr/include/c++/13/bits/ranges_algo.h:38,
                 from /usr/include/c++/13/algorithm:63,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51:
/usr/include/c++/13/bits/ranges_base.h:489:44: note:   'std::ranges::__cust::begin'
  489 |     inline constexpr __cust_access::_Begin begin{};
      |                                            ^~~~~
In file included from /usr/include/c++/13/filesystem:50,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:200:
/usr/include/c++/13/bits/fs_dir.h:607:3: note:   'std::filesystem::__cxx11::begin'
  607 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
In file included from /usr/include/c++/13/bits/stl_iterator_base_types.h:71,
                 from /usr/include/c++/13/bits/stl_algobase.h:65,
                 from /usr/include/c++/13/algorithm:60:
/usr/include/c++/13/bits/iterator_concepts.h:984:10: note:   'std::ranges::__cust_access::begin'
  984 |     void begin(const auto&) = delete;
      |          ^~~~~
cave.cpp:15:27: error: 'end' was not declared in this scope
   15 |         for(auto [idx,as]:answer)test[idx]=as;
      |                           ^~~~~~
cave.cpp:15:27: note: suggested alternatives:
/usr/include/c++/13/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/13/bits/ranges_base.h:490:42: note:   'std::ranges::__cust::end'
  490 |     inline constexpr __cust_access::_End end{};
      |                                          ^~~
/usr/include/c++/13/bits/fs_dir.h:612:3: note:   'std::filesystem::__cxx11::end'
  612 |   end(recursive_directory_iterator) noexcept
      |   ^~~
/usr/include/c++/13/bits/ranges_base.h:137:10: note:   'std::ranges::__cust_access::end'
  137 |     void end(const auto&) = delete;
      |          ^~~