Submission #154236

#TimeUsernameProblemLanguageResultExecution timeMemory
154236stefantagaBulb Game (FXCUP4_bulb)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "bulb.h" using namespace std; struct bec { int st,dr; }val[300005]; bool notbec (int nr) { if (nr==-1||nr==-2) { return 0; } return 1; } void dfs (int x,vector <int> l,vector <int> r) { if (notbec(l[x])) { dfs(l[x],l,r); val[x].st=val[l[x]].st; } else { val[x].st=l[x]; } if (notbec(r[x])) { dfs(r[x],l,r); val[x].dr=val[r[x]].st; } else { val[x].dr=r[x]; } }int marcaj[300005],marcaj2[300005]; int FindWinner(int t,vector<int> l,vector<int> r) { int n= l.size(),poz,poz1,q,ok,ok1,pozitie,i; poz=0; while (poz!=-1&&poz!=-2) { poz=l[poz]; } if (poz==-2) { return 0; } else { dfs(0,l,r); poz=0; ok=0; ok1=0; while (notbec(poz)) { poz1=r[poz]; while (notbec(poz1)) { marcaj[poz1]=1; poz1=l[poz1]; } marcaj2[poz]=1; if (val[r[poz]].st==-2) { ok1=1; } poz=l[poz]; } for (i=0;i<n;i++) { if (notbec(r[i])==0) { if (r[i]==-2) { ok+=notbec(l[0]); } else { ok+=ok1; } } else { if (marcaj[i]==1&&val[r[i]].st==-2) { ok+=max(notbec(l[0]),notbec[r[0]]); } else if (marcaj2[i]==1) { poz=r[i]; if (notbec(i)==0) { if (r[i]==-2) { ok++; continue; } } if (val[poz].st==-2) { ok++; continue; } while (notbec(poz)) { if (val[r[poz]].st==-2) { ok++; break; } poz=l[poz]; } } else { ok+=ok1; } } } if (ok==n) { return 0; } return 1; } } /// -2 albastru,-1 rosu , Al doilea (0) vrea -2 , Primul (1) -1 .

Compilation message (stderr)

bulb.cpp: In function 'int FindWinner(int, std::vector<int>, std::vector<int>)':
bulb.cpp:87:49: warning: pointer to a function used in arithmetic [-Wpointer-arith]
                 ok+=max(notbec(l[0]),notbec[r[0]]);
                                                 ^
bulb.cpp:87:50: error: no matching function for call to 'max(bool, bool (&)(int))'
                 ok+=max(notbec(l[0]),notbec[r[0]]);
                                                  ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from bulb.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
bulb.cpp:87:50: note:   deduced conflicting types for parameter 'const _Tp' ('bool' and 'bool(int)')
                 ok+=max(notbec(l[0]),notbec[r[0]]);
                                                  ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from bulb.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
bulb.cpp:87:50: note:   deduced conflicting types for parameter 'const _Tp' ('bool' and 'bool(int)')
                 ok+=max(notbec(l[0]),notbec[r[0]]);
                                                  ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from bulb.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
bulb.cpp:87:50: note:   mismatched types 'std::initializer_list<_Tp>' and 'bool'
                 ok+=max(notbec(l[0]),notbec[r[0]]);
                                                  ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from bulb.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
bulb.cpp:87:50: note:   mismatched types 'std::initializer_list<_Tp>' and 'bool'
                 ok+=max(notbec(l[0]),notbec[r[0]]);
                                                  ^
bulb.cpp:39:27: warning: unused variable 'q' [-Wunused-variable]
  int n= l.size(),poz,poz1,q,ok,ok1,pozitie,i;
                           ^
bulb.cpp:39:36: warning: unused variable 'pozitie' [-Wunused-variable]
  int n= l.size(),poz,poz1,q,ok,ok1,pozitie,i;
                                    ^~~~~~~