Submission #1152813

#TimeUsernameProblemLanguageResultExecution timeMemory
1152813at128Detecting 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 std; using namespace __gnu_pbds; void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;} void __print(float x) {cerr << x;} void __print(double x) {cerr << x;} void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';} void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';} void __print(bool x) {cerr << (x ? "true" : "false");} template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';} template<typename T> void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";} template <typename T, typename... V> void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);} #ifndef ONLINE_JUDGE #define debug(x...) cerr << "[" << #x << "] = ["; _print(x) #else #define debug(x...) #endif typedef tree< int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset; #define all(v) ((v).begin()), ((v).end()) #define sz(v) ((int)((v).size())) #define pb push_back typedef long long ll; std::vector<int> find_subset(int l1, int u, std::vector<int> w) { int n,l,r; vector<int>res,t,v; n=w.size(); l=l1; r=u; vector<pair<int,int>>v; for(int i=0;i<n;i++){ v.pb({w[i],i}); } sort(all(v)); int i=0,j=1; ll sum=v[0].first; while(j<n){ if(i==j){ break; }else if(sum<l){ sum+=v[j++].first; }else if(sum>r){ sum-=v[i++].first; } if(sum>=l and sum<=r){ break; } } if(sum>=l and sum<=r){ for(int k=i;k<j;k++){ res.pb(v[k].second); } } sort(all(res)); return res; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:64:26: error: conflicting declaration 'std::vector<std::pair<int, int> > v'
   64 |     vector<pair<int,int>>v;
      |                          ^
molecules.cpp:59:18: note: previous declaration as 'std::vector<int> v'
   59 | vector<int>res,t,v;
      |                  ^
molecules.cpp:66:13: error: no matching function for call to 'std::vector<int>::push_back(<brace-enclosed initializer list>)'
   66 |         v.pb({w[i],i});
      |         ~~~~^~~~~~~~~~
In file included from /usr/include/c++/11/vector:67,
                 from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
molecules.cpp:70:17: error: request for member 'first' in 'v.std::vector<int>::operator[](0)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   70 |     ll sum=v[0].first;
      |                 ^~~~~
molecules.cpp:76:25: error: request for member 'first' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)(j ++)))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   76 |             sum+=v[j++].first;
      |                         ^~~~~
molecules.cpp:79:25: error: request for member 'first' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)(i ++)))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   79 |             sum-=v[i++].first;
      |                         ^~~~~
molecules.cpp:87:25: error: request for member 'second' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)k))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   87 |             res.pb(v[k].second);
      |                         ^~~~~~
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
      |         ^~~~