Submission #586356

#TimeUsernameProblemLanguageResultExecution timeMemory
586356LastRoninFriend (IOI14_friend)C++14
Compilation error
0 ms0 KiB
#include "friend.h" #include <bits/stdc++.h> #define ll long long using namespace std; const ll N = 1e3 + 10; vector<ll> g[N]; int findSample(int n,int confidence[],int host[],int protocol[]){ bool eq = 1; for(int j = 1; j < n - 1; j++) { if(protocol[j] != protocol[j + 1]) eq = 0; } if(eq) { if(protocol[1] == 1) { // empty ll sum = 0; for(int j = 0; j < n; j++) sum += confidence[j]; return sum; } else if(protocol[1] == 2) { // full ll mx = 0; for(int j = 0; j < n; j++) mx = max(mx, (ll)confidence[j]); return mx; } else if(protocol[1] == 0) { // tree return -1; } } else { for(int j = 1; j < n; j++) { if(protocol[j] == 0) { g[j].pb(host[j]); g[host[j]].pb(j); } else if(protocol[j] == 1) { for(auto u : g[host[j]]) { g[j].pb(u); g[u].pb(j); } } else if(protocol[j] == 2) { for(auto u : g[host[j]]) { g[j].pb(u); g[u].pb(j); } g[j].pb(host[j]); g[host[j]].pb(j); } } assert(n <= 10); ll mx = 0; for(int j = 0; j < (1<<n); j++) { bool incor = 0; ll sum = 0; for(int i = 0; i < n; i++) { if((1<<i)&j) sum = sum + confidence[i]; } for(int i = 0; i < n; i++) { if((1<<i)&j) { for(auto u : g[i]) if((1<<u)&j) incor = 1; } } if(incor == 0) mx = max(mx, sum); } return mx; } return 0; } /* 6 13 3 6 20 10 15 0 0 0 1 1 2 2 1 0 0 6 13 3 6 20 10 15 0 0 0 1 1 2 2 1 0 0 */ /* #define __MAXSIZE__ 100002 #include "friend.h" using namespace std; // Confidence int confidence[__MAXSIZE__]; // Host int host[__MAXSIZE__]; // Protocol int protocol[__MAXSIZE__]; // Main int main(void) { int n,i; // Number of people assert(scanf("%d",&n)==1); // Confidence for(i=0;i<n;i++) assert(scanf("%d",&confidence[i])==1); // Host and Protocol for(i=1;i<n;i++) assert(scanf("%d %d",&host[i],&protocol[i])==2); // Answer printf("%d\n",findSample(n,confidence,host,protocol)); return 0; } /**/

Compilation message (stderr)

friend.cpp:118:1: warning: "/*" within comment [-Wcomment]
  118 | /**/
      |  
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:36:10: error: 'class std::vector<long long int>' has no member named 'pb'
   36 |     g[j].pb(host[j]);
      |          ^~
friend.cpp:37:16: error: 'class std::vector<long long int>' has no member named 'pb'
   37 |     g[host[j]].pb(j);
      |                ^~
friend.cpp:40:11: error: 'class std::vector<long long int>' has no member named 'pb'
   40 |      g[j].pb(u);
      |           ^~
friend.cpp:41:11: error: 'class std::vector<long long int>' has no member named 'pb'
   41 |      g[u].pb(j);
      |           ^~
friend.cpp:45:11: error: 'class std::vector<long long int>' has no member named 'pb'
   45 |      g[j].pb(u);
      |           ^~
friend.cpp:46:11: error: 'class std::vector<long long int>' has no member named 'pb'
   46 |      g[u].pb(j);
      |           ^~
friend.cpp:48:10: error: 'class std::vector<long long int>' has no member named 'pb'
   48 |     g[j].pb(host[j]);
      |          ^~
friend.cpp:49:16: error: 'class std::vector<long long int>' has no member named 'pb'
   49 |     g[host[j]].pb(j);
      |                ^~