Submission #338714

#TimeUsernameProblemLanguageResultExecution timeMemory
338714NicolaAbusaad2014Cave (IOI13_cave)C++14
Compilation error
0 ms0 KiB
/** * Prof.Nicola **/ #include "cave.h" #include <bits/stdc++.h> using namespace std; template<class T>void re(T&x){cin>>x;} template<class T1,class T2> void re(pair<T1,T2>&x){re(x.first);re(x.second);} template<class T>void re(vector<T>&x){for(long i=0;i<x.size();i++){re(x[i]);}} template<class T>void re(deque<T>&x){for(long i=0;i<x.size();i++){re(x[i]);}} template<class T1,class T2> pair<T1,T2> mp(T1&x,T2&z){return make_pair(x,z);} long long n,turn[5001]={}; set<long>s; set<long>::iterator t; void con(long l,long r,long&arr[]) { t=s.begin(); for(long i=0;i<s.size();i++){ arr[*t]=turn[*t]; t++; } for(long i=0;i<n&&r>=0;i++){ if(!s.count(i)){ if(l){ l--; continue; } arr[i]=(arr[i]^1); r--; } } } long long bin(long long l,long long r,long long x,long&arr[]) { long long mid; while(l<r){ mid=(l+r)/2; con(l,mid,arr); if(tryCombination(arr)==x){ l=mid+1; } else{ con(l,mid,arr); r=mid; } } return l; } void exploreCave(int N) { n=N; long sw[n]={},arr[n]={},ans[n]={}; long x; for(long i=0;i<N;i++){ if(tryCombination(arr)!=i){ con(0,N-i,arr); } x=bin(0,N-i,i,arr); ans[x]=i; sw[i]=(arr[i]^1); turn[i]=sw[i]; s.insert(x); } answer(sw,ans); }

Compilation message (stderr)

cave.cpp:16:29: error: declaration of 'arr' as array of references
   16 | void con(long l,long r,long&arr[])
      |                             ^~~
cave.cpp: In function 'void con(...)':
cave.cpp:19:19: warning: comparison of integer expressions of different signedness: 'long int' and 'std::set<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(long i=0;i<s.size();i++){
      |                  ~^~~~~~~~~
cave.cpp:20:9: error: 'arr' was not declared in this scope
   20 |         arr[*t]=turn[*t];
      |         ^~~
cave.cpp:23:23: error: 'r' was not declared in this scope
   23 |     for(long i=0;i<n&&r>=0;i++){
      |                       ^
cave.cpp:25:16: error: 'l' was not declared in this scope
   25 |             if(l){
      |                ^
cave.cpp:29:13: error: 'arr' was not declared in this scope
   29 |             arr[i]=(arr[i]^1);
      |             ^~~
cave.cpp: At global scope:
cave.cpp:34:56: error: declaration of 'arr' as array of references
   34 | long long bin(long long l,long long r,long long x,long&arr[])
      |                                                        ^~~
cave.cpp: In function 'long long int bin(...)':
cave.cpp:37:11: error: 'l' was not declared in this scope
   37 |     while(l<r){
      |           ^
cave.cpp:37:13: error: 'r' was not declared in this scope
   37 |     while(l<r){
      |             ^
cave.cpp:39:19: error: 'arr' was not declared in this scope
   39 |         con(l,mid,arr);
      |                   ^~~
cave.cpp:40:33: error: 'x' was not declared in this scope
   40 |         if(tryCombination(arr)==x){
      |                                 ^
cave.cpp:48:12: error: 'l' was not declared in this scope
   48 |     return l;
      |            ^
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:55:27: error: cannot convert 'long int*' to 'int*'
   55 |         if(tryCombination(arr)!=i){
      |                           ^~~
      |                           |
      |                           long int*
In file included from cave.cpp:4:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp:64:12: error: cannot convert 'long int*' to 'int*'
   64 |     answer(sw,ans);
      |            ^~
      |            |
      |            long int*
In file included from cave.cpp:4:
cave.h:9:17: note:   initializing argument 1 of 'void answer(int*, int*)'
    9 | void answer(int S[], int D[]);
      |             ~~~~^~~