Submission #167510

# Submission time Handle Problem Language Result Execution time Memory
167510 2019-12-08T18:04:31 Z wildturtle Cave (IOI13_cave) C++14
Compilation error
0 ms 0 KB
#include"cave.h"
#include<bits/stdc++.h>
using namespace std;
int go(int x,int y) {
           for(int i=0;i<n;i++) {
                      if(B[i]>0) A[i]=B[i]-1;
                      else { if(x<=i && i<=y) A[i]=1;
                                 else A[i]=0;
                      }
           }
           return tryCombination(A);
}
int go1(int x,int y) {
           for(int i=0;i<n;i++) {
                      if(B[i]>0) A[i]=B[i]-1;
                      else { if(x>i || i>y) A[i]=0;
                                 else A[i]=1;
                      }
           }           
           return tryCombination(A);
}
void exploreCave(int N) {
           int A[200005],B[200005],C[200005],D[200005];
           int n=N;
           for(int i=0;i<n;i++) {
                      int le=0; int ri=n-1;
                      int a=0;
                      int c=go(0,n-1);
                      if(c>i || c==-1) a=1;
                      while(le<=ri) {
                                 int mid=(le+ri)/2;
                                 if(a==1) {
                                            c=go(le,mid);
                                            if(c>i || c==-1) le=mid;
                                            else ri=mid+1;
                                 }
                                 else {
                                            c=go1(le,mid);
                                            if(c>i || c==-1) le=mid;
                                            else ri=mid+1;
                                 }
                      }
                      if(c==1) B[i]=2;
                      else B[i]=1;
                      C[mid]=i;
                      D[mid]=mid;
           }
           answer(C,D);
}

Compilation message

cave.cpp: In function 'int go(int, int)':
cave.cpp:5:26: error: 'n' was not declared in this scope
            for(int i=0;i<n;i++) {
                          ^
cave.cpp:6:26: error: 'B' was not declared in this scope
                       if(B[i]>0) A[i]=B[i]-1;
                          ^
cave.cpp:6:34: error: 'A' was not declared in this scope
                       if(B[i]>0) A[i]=B[i]-1;
                                  ^
cave.cpp:7:47: error: 'A' was not declared in this scope
                       else { if(x<=i && i<=y) A[i]=1;
                                               ^
cave.cpp:8:39: error: 'A' was not declared in this scope
                                  else A[i]=0;
                                       ^
cave.cpp:11:34: error: 'A' was not declared in this scope
            return tryCombination(A);
                                  ^
cave.cpp: In function 'int go1(int, int)':
cave.cpp:14:26: error: 'n' was not declared in this scope
            for(int i=0;i<n;i++) {
                          ^
cave.cpp:15:26: error: 'B' was not declared in this scope
                       if(B[i]>0) A[i]=B[i]-1;
                          ^
cave.cpp:15:34: error: 'A' was not declared in this scope
                       if(B[i]>0) A[i]=B[i]-1;
                                  ^
cave.cpp:16:45: error: 'A' was not declared in this scope
                       else { if(x>i || i>y) A[i]=0;
                                             ^
cave.cpp:17:39: error: 'A' was not declared in this scope
                                  else A[i]=1;
                                       ^
cave.cpp:20:34: error: 'A' was not declared in this scope
            return tryCombination(A);
                                  ^
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:45:25: error: 'mid' was not declared in this scope
                       C[mid]=i;
                         ^~~
cave.cpp:23:16: warning: unused variable 'A' [-Wunused-variable]
            int A[200005],B[200005],C[200005],D[200005];
                ^