Submission #1172553

#TimeUsernameProblemLanguageResultExecution timeMemory
1172553h1440Detecting Molecules (IOI16_molecules)C++17
100 / 100
39 ms5192 KiB
#include "molecules.h"
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fore(i,a,b) for(lli i = (a), abcdxd = (b); i < abcdxd; i++)
#define f first
#define s second
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define ENDL '\n'
#define sz(s) lli((s).size())
#define pb push_back
using namespace std;
typedef long long lli;
// typedef long long LLI;
typedef pair<lli, lli> ii;
typedef vector<lli> vi;
typedef vector<ii> vii;
typedef long double ld;
#define deb(x) cout << #x << ": " << x << endl;
#define BIGLLI __int128

std::vector<int> find_subset(int l, int r, std::vector<int> w) {
    lli n = sz(w);
    vii v(n+1, ii{0, -1}); fore(i,0,n){
        v[i].f = w[i];
        v[i].s = i;
    }
    // for (auto & i : v) cout << i.f << ' ' << i.s << endl;
    sort(all(v)); fore(i,1,n+1) v[i].f += v[i-1].f;
    // for (auto & i : v) cout << i.f << ' ' << i.s << endl;
    fore(k,1,n+1){
        lli pos = k;
        for (lli pot = n; pot > 0; pot>>=1)
            while ((pos + pot) <= n and (v[pos + pot].f - v[k-1].f) <= r) pos+=pot;
        if (l <= (v[pos].f - v[k-1].f) and (v[pos].f - v[k-1].f) <= r){
            vector<int> ans;
            fore(i,k,pos+1) ans.pb(v[i].s);
            return ans;
        }
    }
    return {};
}

Compilation message (stderr)

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
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...