제출 #556266

#제출 시각아이디문제언어결과실행 시간메모리
556266Talha_TakiDetecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; typedef long long ll; typedef pair <int, int> pii; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector <int> ret; int n = w.size(); vector <pii> W(n); for(int i = 0; i < n; ++i) { W[i] = {w[i], i}; } ll sum = 0; int cnt = 0; while (sum < l) { sum += W[i].first; cnt++ } if (l <= sum && sum <= u) { for(int i = 0; i < cnt; ++i) { ret.push_back(i); } } return ret; }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:23:18: error: 'i' was not declared in this scope
   23 |         sum += W[i].first;
      |                  ^
molecules.cpp:24:14: error: expected ';' before '}' token
   24 |         cnt++
      |              ^
      |              ;
   25 |     }
      |     ~