Submission #145228

#TimeUsernameProblemLanguageResultExecution timeMemory
145228mat_vDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include <cstdio> #include <vector> #include <cassert> #include <bits/stdc++.h> //#include "molecules.h" #define maxn 200005 #define pb push_back #define xx first #define yy second using namespace std; typedef long long ll; 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; 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; } 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; for(int i=0; i<=n; i++){ //cout << i << endl; de = i; ll sum = suff[i]; // cout << i << " " << suff[i] << endl; if(sum > u)break; //cout << sum << endl; ll pom = l - sum; ll prvi; if(pom <= 0){ //cout << i << endl; ima = 1; break; } else{ prvi = lower_bound(pref, pref + n + 1, pom) - pref; } if(prvi > n)prvi = n; if(pref[prvi] + sum > pref[n])continue; if(dobar(pref[prvi] + sum)){ ima = 1; le = prvi; break; } } // cout << de << endl; vector<int>rez; if(!ima)return rez; int koji = n - de; for(int i=1; i<=le; i++)rez.pb(v[i - 1].yy); for(int i=n-1; i>=koji; i--)rez.pb(v[i].yy); return rez; }

Compilation message (stderr)

molecules.cpp:21:8: error: 'pii' was not declared in this scope
 vector<pii>v;
        ^~~
molecules.cpp:21:11: error: template argument 1 is invalid
 vector<pii>v;
           ^
molecules.cpp:21:11: error: template argument 2 is invalid
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:7:12: error: request for member 'push_back' in 'v', which is of non-class type 'int'
 #define pb push_back
            ^
molecules.cpp:24:29: note: in expansion of macro 'pb'
     for(int i=0; i<n; i++)v.pb({w[i], i});;
                             ^~
molecules.cpp:29:20: error: invalid types 'int[int]' for array subscript
         tren += v[i].xx;
                    ^
molecules.cpp:39:24: error: invalid types 'int[int]' for array subscript
         tren += v[i - 1].xx;
                        ^
molecules.cpp:73:43: error: invalid types 'int[int]' for array subscript
     for(int i=1; i<=le; i++)rez.pb(v[i - 1].yy);
                                           ^
molecules.cpp:74:43: error: invalid types 'int[int]' for array subscript
     for(int i=n-1; i>=koji; i--)rez.pb(v[i].yy);
                                           ^