Submission #1332162

#TimeUsernameProblemLanguageResultExecution timeMemory
1332162ChinguunDetecting Molecules (IOI16_molecules)C++20
Compilation error
0 ms0 KiB
#include "molecules.h"
// #include <bits/stdc++.h>
using namespace std;

#define int long long
#define ff first
#define ss second
#define pb push_back
#define ppb pop_back
#define meta int tm = (tl + tr) / 2, x = i * 2 + 1, y = x + 1

const int N = 2e5 + 7;
const int TN = 4 * N;
const int oo = 1e18;
const int mod = 1e9 + 7;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    vii v;
    vi empty, ans;
    for (int i = 0; i < w.size(); i++) {
        v.pb({w[i], i + 1});
    }
    sort (v.begin(), v.end());
    int sum = v[0].ff, tl = 0, tr = 0;
    ans.pb(v[0].ss);
    int cnt = 0;
    while (1) {
        cnt++;
        if (l <= sum && sum <= u) return ans;
        if (sum < l) {
            tr++;
            if (tr >= w.size()) return empty;
            ans.pb(v[tr].ss);
            sum += v[tr].ff;
        }
        else {
            ans.erase(ans.begin());
            sum -= v[tl].ff;
            tl++;
            if (tl >= w.size()) return empty;
        }
        // cout << tl << ' ' << tr << ' ' << sum << '\n';
    }
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<long long int> find_subset(long long int, long long int, std::vector<long long int>)':
molecules.cpp:27:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   27 |     sort (v.begin(), v.end());
      |     ^~~~
      |     short