Submission #145248

# Submission time Handle Problem Language Result Execution time Memory
145248 2019-08-19T11:29:20 Z mat_v Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
#define yy second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int n;
ll pref[maxn];
ll suff[maxn];
int a,b;
bool dobar(ll x){
    if(x >=a && x<=b)return 1;
    return 0;
}
vector<pii>v;
vector<int>uradi(int x, int y){
    vector<int>rezz;
    for(int i=0; i<x; i++)rezz.pb(v[i].yy);
    for(int i=n-1; i>=n-y; i--)rezz.pb(v[i].yy);
    return rezz;
}
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    n = w.size();
    for(int i=0; i<n; i++)v.pb({w[i], i});;
    ll tren = 0;
    a = l;
    b = u;
    for(int i=0; i<n; i++){
        tren += v[i].xx;
        pref[i + 1] = tren;
    }
    if(dobar(pref[n])){
        vector<int> rez;
        for(int i=0; i<n; i++)rez.push_back(i);
        return rez;
    }
    vector<int>rez;
    if(pref[n] < l)return rez;
    tren = 0;
    for(int i=n; i>=1; i--){
        tren += v[i - 1].xx;
        suff[n - i + 1] = tren;
    }
    bool ima = 0;
    int le=0,de=0;
    while(pref[le] < l)le++;
    if(dobar(pref[le])){
        ima = 1;
        return uradi(le,de);
    }
    for(int i=1; i<=n; i++){
        de = i;
        if(suff[de] >= l){
            if(dobar(suff[de]))return uradi(0,de);
            return rez;
        }
        ll sum = pref[le] + suff[de];
        while(pref[le] + suff[de] >= l)le--;
        le++;
        if(dobar(pref[le] + suff[de]))return uradi(max(le,0),de);
    }
    return rez;
}

Compilation message

molecules.cpp:4:9: error: 'pair' does not name a type
 typedef pair<int,int> pii;
         ^~~~
molecules.cpp:6:9: error: 'maxn' was not declared in this scope
 ll pref[maxn];
         ^~~~
molecules.cpp:7:9: error: 'maxn' was not declared in this scope
 ll suff[maxn];
         ^~~~
molecules.cpp:13:1: error: 'vector' does not name a type
 vector<pii>v;
 ^~~~~~
molecules.cpp:14:1: error: 'vector' does not name a type
 vector<int>uradi(int x, int y){
 ^~~~~~
molecules.cpp:20:6: error: 'vector' in namespace 'std' does not name a template type
 std::vector<int> find_subset(int l, int u, std::vector<int> w) {
      ^~~~~~