Submission #1284071

#TimeUsernameProblemLanguageResultExecution timeMemory
1284071talyCave (IOI13_cave)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define pii pair<int, int>
#define tii tuple<int, int, int>
#define lli long long
// #define f first
// #define s second
#define pb push_back
using namespace std;
#include "cave.h"
// void exploreCave(int n);
// void answer(int S[],int D[]);
// int tryCombination(int S[]);
int s[n], d[n];

void solve(int l, int r, int x, bool b){//b=1 se estava para baixo antes
    if(l==r){
        s[x]=0;
        int tc = tryCombination(s);
        if(tc==x)s[x]=1;
        else s[x]=0;
        d[x]=l;
        return;
    }
    int mid = (l+r)/2;
    for (int i=l; i<=mid; i++){
        if(d[i]==-1){
            s[i]=1-s[i];
        }
    }
    int tc = tryCombination(s);
    if(tc==x&&b==1){
        solve(mid+1, r, x, 1);
    }else if (tc==x&&b==0){
        solve(l, mid, x, 1)
    }else if (tc!=x&&b==0){
        solve(mid+1, r, x, 0);
    }else{
        solve(l, mid, x, 0);
    }
}


void exploreCave(int n){
    for (int i=0; i<n; i++){
        d[i]=-1;
        s[n]=0;
    }
    // vector<int> s(n), d(n, -1);
    int c = 0;
    for (int i=0; i<n; i++){
        int tc = tryCombination(s);
        if(tc>i){
            solve(0, n-1, i, 0);
        }else{
            solve(0, n-1, i, 1);
        }
    }
    answer(s, d);
}

Compilation message (stderr)

cave.cpp:13:7: error: 'n' was not declared in this scope; did you mean 'yn'?
   13 | int s[n], d[n];
      |       ^
      |       yn
cave.cpp:13:13: error: 'n' was not declared in this scope; did you mean 'yn'?
   13 | int s[n], d[n];
      |             ^
      |             yn
cave.cpp: In function 'void solve(int, int, int, bool)':
cave.cpp:17:9: error: 's' was not declared in this scope
   17 |         s[x]=0;
      |         ^
cave.cpp:21:9: error: 'd' was not declared in this scope
   21 |         d[x]=l;
      |         ^
cave.cpp:26:12: error: 'd' was not declared in this scope
   26 |         if(d[i]==-1){
      |            ^
cave.cpp:27:13: error: 's' was not declared in this scope
   27 |             s[i]=1-s[i];
      |             ^
cave.cpp:30:29: error: 's' was not declared in this scope
   30 |     int tc = tryCombination(s);
      |                             ^
cave.cpp:34:28: error: expected ';' before '}' token
   34 |         solve(l, mid, x, 1)
      |                            ^
      |                            ;
   35 |     }else if (tc!=x&&b==0){
      |     ~                       
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:45:9: error: 'd' was not declared in this scope
   45 |         d[i]=-1;
      |         ^
cave.cpp:46:9: error: 's' was not declared in this scope
   46 |         s[n]=0;
      |         ^
cave.cpp:51:33: error: 's' was not declared in this scope
   51 |         int tc = tryCombination(s);
      |                                 ^
cave.cpp:58:12: error: 's' was not declared in this scope
   58 |     answer(s, d);
      |            ^
cave.cpp:58:15: error: 'd' was not declared in this scope
   58 |     answer(s, d);
      |               ^