Submission #420987

#TimeUsernameProblemLanguageResultExecution timeMemory
420987marcipan5000Friend (IOI14_friend)C++14
Compilation error
0 ms0 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; bool q1=1,q2=1,q3=1; int n1; int ans=0; int uu; int conff[1002]; vector<int> t[1002]; bool z[15]; int w=0; void rek(int p) { if (p==n1) { for (int i=0;i<n1;i++) { if (z[i]==1) { for (int j=0;j<t[i].size();j++) { if (z[t[i][j]]==1) { return; } } } } ans=max(ans,w); return; } z[p]=0; rek(p+1); z[p]=1; w+=conff[p]; rek(p+1); z[p]=0; w-=conff[p]; return; } const int maxn = (int)1e3; vector<bool> volt; vector<int> par; bool javit(int akt, bool p){ volt[akt] = true; if(par[akt] != -1 && p) return javit(par[akt], !p); for(int x : t[akt]){ if(!volt[x] && (par[x] == -1 || javit(x, !p))){ par[akt] = x; par[x] = akt; return true; } } return false; } int subtask5(int n){ par.assign(n, -1); int maxmatching = 0; for(int i = 0; i < n; i++){ volt.assign(n, false); if(par[i] == -1 && javit(i, false)) maxmatching++; } return n-maxmatching; } bool vo[1002]; pair<int,int> z2; pair<int,int> dfs(int p) { vo[p]=1; pair<int,int> ans; ans.first=0; ans.second=0; for (int i=0;i<t[p].size;i++) { if (vo[t[p][i]]==0) { z2=dfs(t[p][i]); ans.second=max(ans.second,z2.first); ans.first=max(ans.first,z2.first); ans.first=max(ans.first,z2.second+coeff[p]); } } return(ans); } int findSample(int n,int confidence[],int host[],int protocol[]) { n1=n; for (int i=1;i<n;i++) { if (protocol[i]!=0) { q1=0; } if (protocol[i]!=1) { q2=0; } if (protocol[i]!=2) { q3=0; } } if (q3==1) { int ma=0; for (int i=0;i<n;i++) { ma=max(ma,confidence[i]); } return(ma); } if (q2==1) { int ma=0; for (int i=0;i<n;i++) { ma=ma+confidence[i]; } return(ma); } if (q1==1) { z2=rek(0); return(max(z2.first,z2.second)); } for (int i=0;i<n;i++) { conff[i]=confidence[i]; } for (int i=1;i<n;i++) { if (protocol[i]==0) { t[i].push_back(host[i]); t[host[i]].push_back(i); } if (protocol[i]==1) { uu=t[host[i]].size(); for (int j=0;j<uu;j++) { t[i].push_back(t[host[i]][j]); t[t[host[i]][j]].push_back(i); } } if (protocol[i]==2) { uu=t[host[i]].size(); for (int j=0;j<uu;j++) { t[i].push_back(t[host[i]][j]); t[t[host[i]][j]].push_back(i); } t[i].push_back(host[i]); t[host[i]].push_back(i); } } if (n<=10) { /* for (int i2=0;i2<=i;i2++) { for (int j=0;j<t[i2].size();j++) { cout << t[i2][j] << " "; } cout << endl; } cout << endl; */ rek(0); return(ans); } return(subtask5(n)); }

Compilation message (stderr)

friend.cpp: In function 'void rek(int)':
friend.cpp:21:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |                 for (int j=0;j<t[i].size();j++) {
      |                              ~^~~~~~~~~~~~
friend.cpp: In function 'std::pair<int, int> dfs(int)':
friend.cpp:75:25: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' (did you forget the '()' ?)
   75 |     for (int i=0;i<t[p].size;i++) {
      |                    ~~~~~^~~~
      |                             ()
friend.cpp:80:47: error: 'coeff' was not declared in this scope; did you mean 'conff'?
   80 |             ans.first=max(ans.first,z2.second+coeff[p]);
      |                                               ^~~~~
      |                                               conff
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:114:17: error: no match for 'operator=' (operand types are 'std::pair<int, int>' and 'void')
  114 |         z2=rek(0);
      |                 ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from friend.cpp:2:
/usr/include/c++/10/bits/stl_pair.h:390:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch&>::type) [with _T1 = int; _T2 = int; typename std::conditional<std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch&>::type = const std::pair<int, int>&]'
  390 |       operator=(typename conditional<
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:393:41: note:   no known conversion for argument 1 from 'void' to 'std::conditional<true, const std::pair<int, int>&, const std::__nonesuch&>::type' {aka 'const std::pair<int, int>&'}
  390 |       operator=(typename conditional<
      |                 ~~~~~~~~~~~~~~~~~~~~~    
  391 |   __and_<is_copy_assignable<_T1>,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~        
  392 |          is_copy_assignable<_T2>>::value,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  393 |   const pair&, const __nonesuch&>::type __p)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_pair.h:401:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch&&>::type) [with _T1 = int; _T2 = int; typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch&&>::type = std::pair<int, int>&&]'
  401 |       operator=(typename conditional<
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:404:31: note:   no known conversion for argument 1 from 'void' to 'std::conditional<true, std::pair<int, int>&&, std::__nonesuch&&>::type' {aka 'std::pair<int, int>&&'}
  401 |       operator=(typename conditional<
      |                 ~~~~~~~~~~~~~~~~~~~~~
  402 |   __and_<is_move_assignable<_T1>,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  403 |          is_move_assignable<_T2>>::value,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  404 |   pair&&, __nonesuch&&>::type __p)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_pair.h:418:2: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, const _U1&>, std::is_assignable<_T2&, const _U2&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U1 = _U1; _U2 = _U2; _T1 = int; _T2 = int]'
  418 |  operator=(const pair<_U1, _U2>& __p)
      |  ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:418:2: note:   template argument deduction/substitution failed:
friend.cpp:114:17: note:   mismatched types 'const std::pair<_T1, _T2>' and 'void'
  114 |         z2=rek(0);
      |                 ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from friend.cpp:2:
/usr/include/c++/10/bits/stl_pair.h:430:2: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, _U1&&>, std::is_assignable<_T2&, _U2&&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U1 = _U1; _U2 = _U2; _T1 = int; _T2 = int]'
  430 |  operator=(pair<_U1, _U2>&& __p)
      |  ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:430:2: note:   template argument deduction/substitution failed:
friend.cpp:114:17: note:   mismatched types 'std::pair<_T1, _T2>' and 'void'
  114 |         z2=rek(0);
      |                 ^