Submission #875746

#TimeUsernameProblemLanguageResultExecution timeMemory
875746raul2008487Detecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "molecules.h" #define ll int #define all(v) v.begin(), v.end() #define pb push_back #define vl vector<ll> using namespace std; bool check(ll cur, ll low, ll high){ return (cur <= high && cur >= low); } vector<int> find_subset(int l, int u, vector<int> w) { vl ans; vector<pair<ll,ll>> p; ll i, j, n = w.size(), left = 0, r = 1, sum = w[0]; for(i=0;i<n;i++){ p.pb({w[i], i}); } sort(all(p)); bool as = 0; while(r <= n){ if(check(sum, left, u)){ for(i=left+1;i<=r;i++){ ans.pb(p[i-1].se); break; } } else if(sum > u){ left++; sum -= p[l-1].fi; } else{ r++; sum += p[r-1].fi; } } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:23:31: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'se'
   23 |                 ans.pb(p[i-1].se);
      |                               ^~
molecules.cpp:29:27: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'fi'
   29 |             sum -= p[l-1].fi;
      |                           ^~
molecules.cpp:33:27: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'fi'
   33 |             sum += p[r-1].fi;
      |                           ^~
molecules.cpp:14:11: warning: unused variable 'j' [-Wunused-variable]
   14 |     ll i, j, n = w.size(), left = 0, r = 1, sum = w[0];
      |           ^
molecules.cpp:19:10: warning: unused variable 'as' [-Wunused-variable]
   19 |     bool as = 0;
      |          ^~