제출 #101705

#제출 시각아이디문제언어결과실행 시간메모리
101705coldEr66Detecting Molecules (IOI16_molecules)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#include "molecules.h"
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()

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[R++].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;
}

컴파일 시 표준 에러 (stderr) 메시지

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:16:50: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> > >::value_type {aka struct std::pair<int, int>}' has no member named 'X'
     while (sum < l && R < SZ(w)) sum += tmp[R++].X;
                                                  ^
molecules.cpp:18: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:21: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;
                            ^