Submission #1143644

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
11436442025-02-01 08:47:56RufatFriend (IOI14_friend)C++20
Compilation error
0 ms0 KiB
// Global variable to store the best total so far.
int best;
// dp: from a given bitmask of vertices still “active” we record an upper bound.
unordered_map<uint64_t,int> memo;
// rec( mask, cur ) = try to complete an independent set starting from
// the set 'mask' (of vertices still available) having already total weight 'cur'
void rec(uint64_t mask, int cur, const vector<int>& weight,
const vector<uint64_t>& nbr) {
if(mask==0) {
best = max(best, cur);
return;
}
// Use memoization to prune
if(memo.count(mask) && memo[mask] + cur <= best) return;
// Choose a vertex v from mask (say, the least–significant one)
int v = __builtin_ctzll(mask);
// Option 1: take vertex v.
uint64_t mask2 = mask & ~(1ULL << v) & ~nbr[v]; // remove v and its neighbours
rec(mask2, cur + weight[v], weight, nbr);
// Option 2: do not take vertex v.
rec(mask & ~(1ULL << v), cur, weight, nbr);
memo[mask] = best - cur; // record an upper bound for mask
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

friend.cpp:5:15: error: 'uint64_t' was not declared in this scope
    5 | unordered_map<uint64_t,int> memo;
      |               ^~~~~~~~
friend.cpp:1:1: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
  +++ |+#include <cstdint>
    1 | // Global variable to store the best total so far.
friend.cpp:5:15: error: 'uint64_t' was not declared in this scope
    5 | unordered_map<uint64_t,int> memo;
      |               ^~~~~~~~
friend.cpp:5:15: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
friend.cpp:5:15: error: 'uint64_t' was not declared in this scope
friend.cpp:5:15: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
friend.cpp:5:15: error: 'uint64_t' was not declared in this scope
friend.cpp:5:15: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
friend.cpp:5:15: error: 'uint64_t' was not declared in this scope
friend.cpp:5:15: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
friend.cpp:5:15: error: 'uint64_t' was not declared in this scope
friend.cpp:5:15: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
friend.cpp:5:15: error: 'uint64_t' was not declared in this scope
friend.cpp:5:15: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
friend.cpp:5:15: error: 'uint64_t' was not declared in this scope
friend.cpp:5:15: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
friend.cpp:5:15: error: 'uint64_t' was not declared in this scope
friend.cpp:5:15: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
friend.cpp:5:1: error: 'unordered_map' does not name a type
    5 | unordered_map<uint64_t,int> memo;
      | ^~~~~~~~~~~~~
friend.cpp:9:6: error: variable or field 'rec' declared void
    9 | void rec(uint64_t mask, int cur, const vector<int>& weight,
      |      ^~~
friend.cpp:9:10: error: 'uint64_t' was not declared in this scope
    9 | void rec(uint64_t mask, int cur, const vector<int>& weight,
      |          ^~~~~~~~
friend.cpp:9:10: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
friend.cpp:9:25: error: expected primary-expression before 'int'
    9 | void rec(uint64_t mask, int cur, const vector<int>& weight,
      |                         ^~~
friend.cpp:9:34: error: expected primary-expression before 'const'
    9 | void rec(uint64_t mask, int cur, const vector<int>& weight,
      |                                  ^~~~~
friend.cpp:10:10: error: expected primary-expression before 'const'
   10 |          const vector<uint64_t>& nbr) {
      |          ^~~~~
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:36:12: error: 'uint64_t' was not declared in this scope
   36 |     vector<uint64_t> nbr(n, 0ULL);
      |            ^~~~~~~~
friend.cpp:36:12: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
friend.cpp:36:5: error: 'vector' was not declared in this scope
   36 |     vector<uint64_t> nbr(n, 0ULL);
      |     ^~~~~~
friend.cpp:36:22: error: 'nbr' was not declared in this scope
   36 |     vector<uint64_t> nbr(n, 0ULL);
      |                      ^~~
friend.cpp:39:13: error: 'set' was not declared in this scope
   39 |     vector< set<int> > friends(n);
      |             ^~~
friend.cpp:39:17: error: expected primary-expression before 'int'
   39 |     vector< set<int> > friends(n);
      |                 ^~~
friend.cpp:41:12: error: expected primary-expression before 'int'
   41 |     vector<int> weight(n);
      |            ^~~
friend.cpp:43:9: error: 'weight' was not declared in this scope
   43 |         weight[i] = confidence[i];
      |         ^~~~~~
friend.cpp:51:13: error: 'friends' was not declared in this scope
   51 |             friends[i].insert(h);
      |             ^~~~~~~
friend.cpp:55:26: error: 'friends' was not declared in this scope
   55 |             for (int f : friends[h]) {
      |                          ^~~~~~~
friend.cpp:61:13: error: 'friends' was not declared in this scope
   61 |             friends[i].insert(h);
      |             ^~~~~~~
friend.cpp:72:22: error: 'friends' was not declared in this scope
   72 |         for (int j : friends[i]) {
      |                      ^~~~~~~
friend.cpp:80:5: error: 'memo' was not declared in this scope
   80 |     memo.clear();
      |     ^~~~
friend.cpp:82:13: error: expected ';' before 'all'
   82 |     uint64_t all = (n==64 ? ~0ULL : ((1ULL << n) - 1));
      |             ^~~~
      |             ;
friend.cpp:83:9: error: 'all' was not declared in this scope
   83 |     rec(all, 0, weight, nbr);
      |         ^~~
friend.cpp:83:17: error: 'weight' was not declared in this scope
   83 |     rec(all, 0, weight, nbr);
      |                 ^~~~~~
friend.cpp:83:5: error: 'rec' was not declared in this scope
   83 |     rec(all, 0, weight, nbr);
      |     ^~~