답안 #54135

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
54135 2018-07-02T12:59:30 Z WLZ Detecting Molecules (IOI16_molecules) C++17
컴파일 오류
0 ms 0 KB
#include "molecules.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

vector<int> find_subset(int n, int l, int u, vector<int> w) {
  vector< pair<int, int> > v;
  for (int i = 0; i < n; i++) {
    v.emplace_back(w[i], i);
  }
  sort(v.begin(), v.end());
  int i = 0, j = 0;
  long long cur = 0ll;
  vector<int> was(n, 0);
  int cnt = 0;
  for (;;) {
    while (i < n && cur < (long long) l) {
      was[v[i].second] = 1;
      cur += (long long) v[i++].first;      
      cnt++;
    }
    while (j < n && cur > (long long) u) {
      was[v[j].second] = 0;
      cur -= (long long) v[j++].first;
      cnt--;
    }
    if (cur >= l && cur <= u) {
      cout << cnt << '\n';
      vector<int> ans;
      for (int i = 0; i < n; i++) {
        if (was[i]) {
          ans.push_back(i);
        }
      }
      return ans;
    }
    if (i >= n || j >= n) {
      break;
    }
  }
  cout << "0\n";
  return;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, int, std::vector<int>)':
molecules.cpp:45:3: error: return-statement with no value, in function returning 'std::vector<int>' [-fpermissive]
   return;
   ^~~~~~