Submission #313602

#TimeUsernameProblemLanguageResultExecution timeMemory
313602amunduzbaevFriend (IOI14_friend)C++14
Compilation error
0 ms0 KiB
//#include "grader.cpp" #include "friend.h" #include <bits/stdc++.h> using namespace std; #define pb(n) push_back(n) int findSample(int n,int c[],int h[],int p[]){ vector<int>v[n]; if(n<=10){ for(int i=1;i<n;i++){ if(p[i]==0){ v[h[i]].pb(i); v[i].pb(h[i]); } else { if(p[i]==2){ v[h[i]].pb(i); v[i].pb(h[i]); } for(auto x:v[h[i]]){ v[x].pb(i); v[i].pb(x); } } } int ans=0; if(n<=10){ int i=1; while(i<(1<<n)){ int cost=0; vector<bool>used(n,0); for(int j=0;j<n;j++){ if(!((1<<j)&i)) continue; bool t=true; for(auto x:v[j]) if(used[x]) t=false; if(t){ cost+=c[j]; used[j]=true; } } ans=max(ans,cost); i++; } } } else if(p[1]==1){ for(int i=0;i<n;i++){ ans+=c[i]; } } else{ for(int i=0;i<n;i++){ ans=max(ans,c[i]); } } return ans; } /* 6 13 3 6 20 10 15 0 0 0 1 2 0 0 0 1 2 1 0 */

Compilation message (stderr)

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:48:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   48 |             ans+=c[i];
      |             ^~~
      |             abs
friend.cpp:53:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   53 |             ans=max(ans,c[i]);
      |             ^~~
      |             abs
friend.cpp:57:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   57 |  return ans;
      |         ^~~
      |         abs