Submission #1147649

#TimeUsernameProblemLanguageResultExecution timeMemory
1147649gulmixDetecting Molecules (IOI16_molecules)C++20
Compilation error
0 ms0 KiB
#include "molecules.h"
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
#define oset tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>

vector<int> find_subset(int l, int r, vector<int> w){
    int n = w.size()
    vector<pair<int, int>> a(n);
    for(int i = 0; i < n; i++){
        a[i] = {w[i], i};
    }
    sort(all(a));
    int cur = 0, lx = 0;
    for(int i = 0; i < n; i++){
        while(lx < n && cur < l){
            cur += a[lx++].first;
        }
        if(cur >= l && cur <= r){
            vector<int> res;
            for(int j = i; j < lx; j++){
                res.push_back(a[j].second);
            }
            sort(all(res));
            return res;
        }
        cur -= a[i].first;
    }
    return vector<int>();
}

//int main(){
//    ios::sync_with_stdio(false);
//    cin.tie(0);
//    //ifstream cin("cycle2.in");
//    //ofstream cout("cycle2.out");
//    vector<int> b = {15, 17, 16, 18};
//    vector<int> a = find_subset(10, 20, b);
//    for(auto &i: a)cout << i << ' ';
//}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:13:5: error: expected ',' or ';' before 'vector'
   13 |     vector<pair<int, int>> a(n);
      |     ^~~~~~
molecules.cpp:15:9: error: 'a' was not declared in this scope
   15 |         a[i] = {w[i], i};
      |         ^
molecules.cpp:17:14: error: 'a' was not declared in this scope
   17 |     sort(all(a));
      |              ^
molecules.cpp:8:16: note: in definition of macro 'all'
    8 | #define all(x) x.begin(), x.end()
      |                ^
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
      |         ^~~~