제출 #545084

#제출 시각아이디문제언어결과실행 시간메모리
545084LunaMemeDetecting Molecules (IOI16_molecules)C++14
컴파일 에러
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; typedef pair<int, int> ii; typedef vector<pair<int, int>> vii; typedef vector<int> vi; typedef longA long ll; #define PB push_back #define MP make_pair #define FOR(i, x, y) for (int i = x; i < y ; i ++) struct weight{ int val, i; weight(int val, int i) : val(val), i(i) {} bool operator<(const weight& rhs){ return val < rhs.val; } }; struct CompareWeight{ bool operator()(const weight& lhs, const weight& rhs){ return lhs.val > rhs.val; } }; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<weight> v; FOR(i, 0, (int)w.size()){ v.PB(weight(w[i], i)); } sort(v.begin(), v.end()); vi sol; ll sum = 0; priority_queue<weight, vector<weight>, CompareWeight> p; if (v[0].val > u) return sol; FOR(i, 0, (int)w.size()){ if (sum + v[i].val < l){ sum += v[i].val; p.push(v[i]); } else if (sum +v[i].val <= u){ p.push(v[i]); break; } else { weight mn = p.top(); p.pop(); sum += v[i].val - mn.val; p.push(v[i]); if (sum >= l){ break; } } if (i == (int)w.size() - 1){ return std::vector<int>(0); } } while(!p.empty()){ weight a = p.top(); p.pop(); sol.PB(a.i); } return sol; } /*int main() { int n, l, u; assert(3 == scanf("%d %d %d", &n, &l, &u)); std::vector<int> w(n); for (int i = 0; i < n; i++) assert(1 == scanf("%d", &w[i])); std::vector<int> result = find_subset(l, u, w); printf("%d\n", (int)result.size()); for (int i = 0; i < (int)result.size(); i++) printf("%d%c", result[i], " \n"[i == (int)result.size() - 1]); }*/

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

molecules.cpp:7:9: error: 'longA' does not name a type; did you mean 'long'?
    7 | typedef longA long ll;
      |         ^~~~~
      |         long
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:31:5: error: 'll' was not declared in this scope; did you mean 'l'?
   31 |     ll sum = 0;
      |     ^~
      |     l
molecules.cpp:38:13: error: 'sum' was not declared in this scope
   38 |         if (sum + v[i].val < l){
      |             ^~~