Submission #997090

#TimeUsernameProblemLanguageResultExecution timeMemory
997090codefoxDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define pii pair<int, int> int* find_subset(int l, int u, int *w) { vector<pii> nums; int c = 1; for (int ele:w) nums.push_back({ele, c++}); sort(nums.begin(), nums.end()); int left=0, right=0; long long sum = 0; while (sum <= l) { sum += nums[right].first; right++; } right--; sum -= nums[right].first; while (sum <= u) { sum += nums[right].first; right++; sum -= nums[left].first; left++; } right--; sum -= nums[right].first; left--; sum -= nums[left].first; if (sum >= l) {ac int ans[right-left]; for (int i = left; i < right; i++) { ans[i-left] = nums[i].second; } return ans; } else { int ans[0]; return ans; } }

Compilation message (stderr)

molecules.cpp: In function 'int* find_subset(int, int, int*)':
molecules.cpp:11:15: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   11 |  for (int ele:w) nums.push_back({ele, c++});
      |               ^
      |               std::begin
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from molecules.cpp:1:
/usr/include/c++/10/valarray:1224:5: note: 'std::begin' declared here
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
molecules.cpp:11:15: error: 'end' was not declared in this scope; did you mean 'std::end'?
   11 |  for (int ele:w) nums.push_back({ele, c++});
      |               ^
      |               std::end
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from molecules.cpp:1:
/usr/include/c++/10/valarray:1244:5: note: 'std::end' declared here
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
molecules.cpp:35:3: error: 'ac' was not declared in this scope; did you mean 'c'?
   35 |  {ac
      |   ^~
      |   c
molecules.cpp:39:4: error: 'ans' was not declared in this scope; did you mean 'abs'?
   39 |    ans[i-left] = nums[i].second;
      |    ^~~
      |    abs
molecules.cpp:41:10: error: 'ans' was not declared in this scope; did you mean 'abs'?
   41 |   return ans;
      |          ^~~
      |          abs
molecules.cpp:46:10: warning: address of local variable 'ans' returned [-Wreturn-local-addr]
   46 |   return ans;
      |          ^~~
molecules.cpp:45:7: note: declared here
   45 |   int ans[0];
      |       ^~~