Submission #295779

# Submission time Handle Problem Language Result Execution time Memory
295779 2020-09-09T23:09:03 Z Ahmad_Hasan Cave (IOI13_cave) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "cave.h"

using namespace std;

void exploreCave(int n){
    vector<int>fnd(n,-1);
    vector<int>kys(n,-1);
    vector<int>stt(n,-1);
    vector<int>s2(n,-1),d(n,-1);
    for(int i=0;i<n;i++){
        vector<int>s(n,1);
        for(int j=0;j<n;j++){
            if(d[j]!=-1){
                s[j]=s2[j];
            }
        }
        int inp;

        inp=tryCombination(s);
        int st;
        if(inp>i||inp==-1){
            st=1;
        }else{
            st=0;
        }
        stt[i]=st;

        int l=0,r=n-1;
        while(l<=r){
            int mid=l+(r-l)/2;
            for(int j=l;j<=mid;j++){
                if(d[j]!=-1){
                    s[j]=s2[j];
                }else{
                    s[j]=st;
                }
            }
            for(int j=mid+1;j<=r;j++){
                if(d[j]!=-1){
                    s[j]=s2[j];
                }else{
                    s[j]=!st;
                }
            }
            inp=tryCombination(s);
            int nst;
            if(inp>i||inp==-1){
                r=mid;
            }else{
                l=mid+1;
            }
            if(l==r){
                fnd[i]=l;
                d[l]=i;
                s2[l]=st;
                break;
            }

        }
    }
    answer(s2,d);
}


/***
8
5
3 1
7 0
6 4
0 5
5 7
*/

Compilation message

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:20:28: error: cannot convert 'std::vector<int>' to 'int*'
   20 |         inp=tryCombination(s);
      |                            ^
      |                            |
      |                            std::vector<int>
In file included from cave.cpp:2:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp:46:32: error: cannot convert 'std::vector<int>' to 'int*'
   46 |             inp=tryCombination(s);
      |                                ^
      |                                |
      |                                std::vector<int>
In file included from cave.cpp:2:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp:47:17: warning: unused variable 'nst' [-Wunused-variable]
   47 |             int nst;
      |                 ^~~
cave.cpp:62:12: error: cannot convert 'std::vector<int>' to 'int*'
   62 |     answer(s2,d);
      |            ^~
      |            |
      |            std::vector<int>
In file included from cave.cpp:2:
cave.h:9:17: note:   initializing argument 1 of 'void answer(int*, int*)'
    9 | void answer(int S[], int D[]);
      |             ~~~~^~~