Submission #1129567

#TimeUsernameProblemLanguageResultExecution timeMemory
1129567enzyCave (IOI13_cave)C++20
Compilation error
0 ms0 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; const int maxn=5010; int ja[maxn], pos[maxn], val[maxn]; bool check(int mid, int val, int n, int obj){ int ask[n]; for(int i=0;i<mid;i++) ask[i]=val; for(int i=mid;i<n;i++) ask[i]=1-val; for(int j=0;j<obj;j++) ask[pos[j]]=val[j]; int x=tryCombination(ask); return x>obj; } void exploreCave(int n){ memset(ja,0,sizeof(ja)); int ans1[n], ans2[n]; for(int i=0;i<n;i++){ int ask[n]; memset(ask,0,sizeof(ask)); for(int j=0;j<=i;j++) ask[pos[j]]=val[j]; int a=tryCombination(ask), atval; if(a==-1||a>i) atval=0; // então o botão da porta i, tem q ser 0 else atval=1; int l=0, r=n-1; while(l<r){ int mid=(l+r)/2; if(check(mid,atval,n,i)) r=mid; else l=mid+1; } pos[i]=l; val[i]=atval; ja[l]++; ans1[l]=atval; ans2[l]=i; } answer(ans1,ans2); }

Compilation message (stderr)

cave.cpp: In function 'bool check(int, int, int, int)':
cave.cpp:10:43: error: invalid types 'int[int]' for array subscript
   10 |     for(int j=0;j<obj;j++) ask[pos[j]]=val[j];
      |                                           ^