Submission #101704

#TimeUsernameProblemLanguageResultExecution timeMemory
101704coldEr66Detecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#include "molecules.h"
#define SZ(a) (int)a.size()

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
  vector<int> ret;
  vector<pair<int,int> > tmp;
  for (int i=0;i<SZ(w);i++) tmp.emplace_back(w[i],i);
  sort(ALL(tmp));

  long long sum = 0;
  int L = 0, R = 0;
  for (;L<SZ(w);L++) {
    while (sum < l && R < SZ(w)) sum += tmp[i].X;
    if (l <= sum && sum <= u) {
      for (int i=L;i<=R;i++) ret.emplace(tmp[i].Y);
      break;
    }
    if (L < R) sum -= w[L].X;
  }
  return ret;
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:10:8: error: 'ALL' was not declared in this scope
   sort(ALL(tmp));
        ^~~
molecules.cpp:10:8: note: suggested alternative: 'P_ALL'
   sort(ALL(tmp));
        ^~~
        P_ALL
molecules.cpp:15:45: error: 'i' was not declared in this scope
     while (sum < l && R < SZ(w)) sum += tmp[i].X;
                                             ^
molecules.cpp:17:49: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> > >::value_type {aka struct std::pair<int, int>}' has no member named 'Y'
       for (int i=L;i<=R;i++) ret.emplace(tmp[i].Y);
                                                 ^
molecules.cpp:20:28: error: request for member 'X' in 'w.std::vector<int>::operator[](((std::vector<int>::size_type)L))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}'
     if (L < R) sum -= w[L].X;
                            ^