Submission #1220470

#TimeUsernameProblemLanguageResultExecution timeMemory
1220470nickolasarapidisDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define F first #define S second vector<int> find_subset(int l, int r, vector<int> w){ int N = w.size(), sum = 0; vector<pair<int, int>> W(N); for(int i = 0; i < N; i++){ W[i] = {w[i], i}; } sort(W.begin(), W.end()); int left = 0; for(int right = 0; right < N; r++){ while(left < N and sum > r){ sum -= W[left].F; left++; } if(sum >= l and sum <= r){ for(int i = left; i <= right; i++){ ans.push_back(W[i].S); } return ans; } sum += W[right].F; } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:24:33: error: 'ans' was not declared in this scope; did you mean 'abs'?
   24 |                                 ans.push_back(W[i].S);
      |                                 ^~~
      |                                 abs
molecules.cpp:26:32: error: 'ans' was not declared in this scope; did you mean 'abs'?
   26 |                         return ans;
      |                                ^~~
      |                                abs
molecules.cpp:30:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
   30 |         return ans;
      |                ^~~
      |                abs
molecules.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~