제출 #380679

#제출 시각아이디문제언어결과실행 시간메모리
380679madlogicDetecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<int> res; int n = (int) w.size(); for (int i = 0; i < n; i++) { if (w[i] >= l && w[i] <= u) { return {i}; } } vector<pair<int, int>> nums; for (int i = 0; i < n; i++) { if (w[i] <= u) { nums.emplace_back(w[i], i); } } sort(nums.rbegin(), nums.rend()); int cur = 0; vector<int> res; for (auto& [x, y] : nums) { if (cur + x > u) { continue; } cur += x; res.push_back(y); } return res; }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:21:15: error: redeclaration of 'std::vector<int> res'
   21 |   vector<int> res;
      |               ^~~
molecules.cpp:6:15: note: 'std::vector<int> res' previously declared here
    6 |   vector<int> res;
      |               ^~~