Submission #1124216

#TimeUsernameProblemLanguageResultExecution timeMemory
1124216epicci23Rarest Insects (IOI22_insects)C++17
Compilation error
0 ms0 KiB
#include "insects.h" #include "bits/stdc++.h" using namespace std; const int N = 2e3 + 5; int vis[N], D , tot = 0 , kill[N]; inline bool Add(int x){ if(vis[x]) return 0; vis[x]=1; tot++; move_inside(x); return 1; } inline bool Rem(int x){ if(!vis[x]) return 0; vis[x]=0; tot--; move_outside(x); return 1; } inline int Get(){ return press_button(); } int min_cardinality(int n){ for(int i=0;i<n;i++){ Add(i); if(i == 0 || Get() == 1) continue; Rem(i); } D = tot; if(D > n / 2) return 1; if(D == 1) return n; int l = 2 , r = n / D , ans = 1; while(l <= r){ int B = (l + r) / 2; vector<int> to_kill; for(int i = 0 ; i < n ; i++){ if(vis[i] || kill[i]) continue; Add(i); if(tot > B && Get() > B){ Rem(i); to_kill.push_back(i); } } if(tot == B * D){ ans = B; l = B + 1; } else{ for(int x : to_kill) kill[x] = 1; r = tot / D; } } return ans; }

Compilation message (stderr)

insects.cpp:7:33: error: 'int kill [2005]' redeclared as different kind of entity
    7 | int vis[N], D , tot = 0 , kill[N];
      |                                 ^
In file included from /usr/include/c++/11/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:43,
                 from insects.cpp:2:
/usr/include/signal.h:112:12: note: previous declaration 'int kill(__pid_t, int)'
  112 | extern int kill (__pid_t __pid, int __sig) __THROW;
      |            ^~~~
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:45:26: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   45 |       if(vis[i] || kill[i]) continue;
      |                          ^
insects.cpp:57:34: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   57 |       for(int x : to_kill) kill[x] = 1;
      |                                  ^
insects.cpp:57:36: error: assignment of read-only location '*(kill + ((sizetype)x))'
   57 |       for(int x : to_kill) kill[x] = 1;
      |                            ~~~~~~~~^~~