Submission #1191412

#TimeUsernameProblemLanguageResultExecution timeMemory
1191412nekolieDetecting Molecules (IOI16_molecules)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int r, vector<int> a) { int n = a.size(); pair<int,int> risa[n]; for (int i = 0; i < n; i++) risa[i].first = a[i], risa[i].second = i; sort(risa,risa+n); long long suma[n]; suma[0] = risa[0].first; for (int i = 1; i < n; i++) suma[i] = suma[i-1]+risa[i].first; vector<int> odp; for (int k = 1; k <= n; k++) { if (suma[k-1] > r || (k < n && suma[n-1]-suma[n-k-1] < l)) continue; vector<pair<int,int>> op; for (int i = 0; i < k; i++) op.push_back({i,n-i-1}); while (op.back().first > op.back().second) odp.push_back(risa[op[i].first].second), op.pop_back(); long long ile = suma[k-1]; for (int i = 0; i < op.size(); i++) { if (ile < l) ile += risa[op[i].second].first-risa[op[i].first].first, odp.push_back(risa[op[i].second].second); else odp.push_back(risa[op[i].first].second); } break; } return odp; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:21:35: error: 'i' was not declared in this scope
   21 |             odp.push_back(risa[op[i].first].second), op.pop_back();
      |                                   ^
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
      |         ^~~~