Hi, trying to solve DAVIDG problem, I paste the code and selected g++4.3.2 (is the only c++ option available), and the judge respond was compilation error.
Submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ve vector
#define pi pair<ll,ll>
#define fi first
#define sc second
#define mp make_pair
#define mod 1000000007
ll t, n, a, b, p, w;
ll who[1000];
struct node {
ll x, y;
ld w;
node(ll x, ll y, ld w) {this->x = x, this->y = y, this->w = w;}
bool operator<(node &o) {return w<o.w;}
};
ve<node> v;
ve<pi> e;
ll father(ll i) {
if (who[i] == i) return i;
return who[i] = father(who[i]);
}
inline ld dis(pi &i, pi &j) {
return sqrt((i.fi-j.fi)(i.fi-j.fi) + (i.sc-j.sc)(i.sc-j.sc));
}
ll solve() {
cin >> n >> p;
e.clear();
v.clear();
for (ll i=0; i<n; ++i) {
who[i] = i;
cin >> a >> b;
e.push_back(mp(a,b));
int aux = e.size();
for (int j=0; j+1<aux; ++j)
v.push_back(node(i,j,dis(e[j],e[aux-1])));
}
sort(v.begin(),v.end());
w = 0;
for (size_t i=0; i<v.size(); ++i) {
ll f1 = father(v[i].x), f2 = father(v[i].y);
if (f1 != f2) {
who[f1] = who[f2] = min(f1,f2);
w += (ll)ceil(v[i].w*p)%mod;
}
}
return w;
}
int main() {
cin >> t;
for (int i=1; i<=t; ++i)
cout << "Scenario #" << i << ": " << solve() << "\n";
return 0;
}
Compilation error:
/usr/include/c++/4.3/bits/stl_algo.h: In function 'const _Tp& std::__median(const _Tp&, const _Tp&, const _Tp&) [with _Tp = node]':
/usr/include/c++/4.3/bits/stl_algo.h:1919: instantiated from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator > >, _Size = int]'
/usr/include/c++/4.3/bits/stl_algo.h:4783: instantiated from 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator > >]'
prog.cpp:47: instantiated from here
/usr/include/c++/4.3/bits/stl_algo.h:93: error: no match for 'operator<' in '__a < __b'
prog.cpp:20: note: candidates are: bool node::operator<(node&)
/usr/include/c++/4.3/bits/stl_algo.h:94: error: no match for 'operator<' in '__b < __c'
prog.cpp:20: note: candidates are: bool node::operator<(node&)
/usr/include/c++/4.3/bits/stl_algo.h:96: error: no match for 'operator<' in '__a < __c'
prog.cpp:20: note: candidates are: bool node::operator<(node&)
/usr/include/c++/4.3/bits/stl_algo.h:100: error: no match for 'operator<' in '__a < __c'
prog.cpp:20: note: candidates are: bool node::operator<(node&)
/usr/include/c++/4.3/bits/stl_algo.h:102: error: no match for 'operator<' in '__b < __c'
prog.cpp:20: note: candidates are: bool node::operator<(node&)
But ideone compile and run just fine. if someone please have any idea of what is happening and could help telling me if i made a mistake, it would be awesome.