Submission #297922

# Submission time Handle Problem Language Result Execution time Memory
297922 2020-09-12T07:38:15 Z Azimjon Detecting Molecules (IOI16_molecules) C++17
Compilation error
0 ms 0 KB
#include "molecules.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<long long> vi;
typedef vector<pair<long long, long long>>  vii;

std::vector<int> find_subset(int l, int r, std::vector<int> w) {
    int n = w.size();
    vii a(n);
    for (int i = 0; i < n; i++)
        a[i] = {w[i], i};
    
    sort(a.begin(), a.end());

    vi p = {0}, s = {0};
    for (auto [f, s]: a)
        p.push_back(p.back() + f);    
    reverse(a.begin(), a.end());
    for (auto [f, e]: a)
        s.push_back(s.back() + f);
    reverse(a.begin(), a.end());
    xtp1(s);
    for (int i = 0; i < n; i++) {
        int x = p[i];
        int y = r - p[i];

        auto it = lower_bound(s.begin(), s.end(), y - 1);
        int o = it - s.begin();
        int yi = x + *it;

        o = n - o;
     /*   xtp1(i);
        xtp1(o);
        xtp1(x);
        xtp1(y);
        xtp1(yi);
        xtp1("\n");*/

        if (o <= i) continue;

        if (l <= yi && yi <= r) {
            vector<int> jv;
            for (int k = 0; k < i; k++)
                jv.push_back(a[k].second);
            for (int k = o; k < n; k++)
                jv.push_back(a[k].second);
            return jv;
        }
    }

    return vector<int>();
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:25:5: error: 'xtp1' was not declared in this scope
   25 |     xtp1(s);
      |     ^~~~