Submission #607488

#TimeUsernameProblemLanguageResultExecution timeMemory
607488skittles1412Friend (IOI14_friend)C++17
19 / 100
138 ms65536 KiB
#include "bits/extc++.h" using namespace std; template <typename T> void dbgh(const T& t) { cerr << t << endl; } template <typename T, typename... U> void dbgh(const T& t, const U&... u) { cerr << t << " | "; dbgh(u...); } #ifdef DEBUG #define dbg(...) \ cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; \ dbgh(__VA_ARGS__); #else #define dbg(...) #define cerr \ if (false) \ cerr #endif #define endl "\n" #define long int64_t #define sz(x) int((x).size()) const int maxn = 1e5 + 5; int arr[maxn]; vector<int> graph[maxn]; int findSample(int n, int _arr[], int host[], int protocol[]) { copy(_arr, _arr + n, arr); for (int i = 1; i < n; i++) { if (protocol[i] == 0 || protocol[i] == 2) { graph[i].push_back(host[i]); } if (protocol[i] == 1 || protocol[i] == 2) { graph[i].insert(graph[i].end(), begin(graph[host[i]]), end(graph[host[i]])); } for (auto& a : graph[i]) { graph[a].push_back(i); } } if (n <= 10) { int ans = 0; for (int i = 0; i < (1 << n); i++) { int cans = 0; for (int j = 0; j < n; j++) { if ((i >> j) & 1) { cans += arr[j]; for (auto& a : graph[j]) { if ((i >> a) & 1) { goto loop; } } } } ans = max(ans, cans); loop:; } return ans; } if (protocol[0] == 1) { return accumulate(arr, arr + n, 0); } else if (protocol[0] == 2) { return *max_element(arr, arr + n); } }

Compilation message (stderr)

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:74:1: warning: control reaches end of non-void function [-Wreturn-type]
   74 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...