Submission #519791

#TimeUsernameProblemLanguageResultExecution timeMemory
519791yhlasDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" using namespace std; int n, e, l, r, md, jog; vector<int> a,d; map <int, long long> p; vector <pair <int, int>> u; vector<int> find_subset(int x, int y, vector<int> v){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); n = v.size(); for (int i = 0; i < n; i++) u.push_back({v[i], i}); sort(u.begin(), u.end()); for (int i = 0; i < n; i++) p[i] = p[i - 1] + u[i].first; for (int i = 0; i < n; i++){ l = i; r = n - 1; jog = -1; while (l <= r){ md = (l + r) / 2; if (y < p[md] - p[i - 1]) r = md - 1; else if (x > p[md] - p[i - 1]) l = md + 1; else{ e = i; jog = md; break; } } if (jog != -1) break; } for (int i = e; i <= jog; i++) a.push_back(u[i].second); sort(a.begin(), a.end()); return a; } int main(){ cin >> o >> b >> c; for (int i = 0; i < o; i++) cin >> k, d.push_back(k); find_subset(b, c, d); for (int i = 0; i < a.size(); i++) cout << a[i] << " "; }

Compilation message (stderr)

molecules.cpp: In function 'int main()':
molecules.cpp:31:9: error: 'o' was not declared in this scope
   31 |  cin >> o >> b >> c;
      |         ^
molecules.cpp:31:14: error: 'b' was not declared in this scope
   31 |  cin >> o >> b >> c;
      |              ^
molecules.cpp:31:19: error: 'c' was not declared in this scope
   31 |  cin >> o >> b >> c;
      |                   ^
molecules.cpp:32:37: error: 'k' was not declared in this scope
   32 |  for (int i = 0; i < o; i++) cin >> k, d.push_back(k);
      |                                     ^
molecules.cpp:34:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |  for (int i = 0; i < a.size(); i++) cout << a[i] << " ";
      |                  ~~^~~~~~~~~~