Submission #1232093

#TimeUsernameProblemLanguageResultExecution timeMemory
1232093cpdreamerDetecting Molecules (IOI16_molecules)C++20
100 / 100
35 ms5192 KiB
#include "molecules.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long INF = 1e17;
typedef long long ll;
const ll MOD = 1000002022;
#define F first
#define P pair
#define S second
#define pb push_back
#define V vector
#define all(v) v.begin(), v.end()
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    int n=(int)w.size();
    for (int i=0;i<n;i++) {
        if (w[i]>=l && w[i]<=u) {
            return {i};
        }
    }
    V<P<ll,int>>vp(n);
    for (int i=0;i<n;i++) {
        vp[i]={w[i],i};
    }
    sort(all(vp));
    ll s=vp[0].F;
    int p1=0,p2=0;
    while (p2<n && p1<n) {
        if (s>=l && s<=u) {
            V<int>id;
            for (int i=p1;i<=p2;i++) {
                id.pb(vp[i].S);
            }
            return id;
        }
        if (s>u) {
            if (p1<n) {
                s-=vp[p1].F;
            }
            p1++;
        }
        else {
            p2++;
            if (p2<n) {
                s+=vp[p2].F;
            }
        }
    }
    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...