| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 669980 | alvingogo | Towns (IOI15_towns) | C++14 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "towns.h"
using namespace std;
int hubDistance(int n, int sub) {
vector<int> dist0(n);
for (int i = 1; i < n; ++i) {
dist0[i] = getDistance(0, i);
}
int a = max_element(dist0.begin(), dist0.end()) - dist0.begin();
vector<int> dist(n);
dist[0] = dist0[a];
for (int i = 1; i < n; ++i) {
dist[i] = i == a ? 0 : getDistance(i, a);
}
int b = max_element(dist.begin(), dist.end()) - dist.begin();
vector<int> pos(n);
pos[0] = (dist0[a] - dist0[b] + dist[b]) >> 1;
for (int i = 1; i < n; ++i) {
pos[i] = min(pos[0], (dist0[a] - dist0[i] + dist[i]) >> 1);
}
int ans = numeric_limits<int>::max();
map<int, vector<int>> mp;
for (int i = 0; i < n; ++i) {
ans = min(ans, max(pos[i], dist[b] - pos[i]));
mp[pos[i]].push_back(i);
}
vector<int> dis2(n);
for(auto h:mp){
for(auto z:h){
dis2[z]=f(i,z)-pos[i]+abs(mp,h.fs);
}
}
int at=1;
vector<int> vis(n),pp(n);
int cnt=0,lo=0;
for(int i=0;i<n;i++){
int u=0;
for(int j=0;j<n;j++){
if(f(i,j)!=dis2[i]+dis2[j]){
u++;
}
}
if(u>n/2){
at=-1;
}
//cout << i << " " << u << "\n";
}
return at*ans;
}
Compilation message (stderr)
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:12:53: warning: conversion from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'} to 'int' may change value [-Wconversion]
12 | int a = max_element(dist0.begin(), dist0.end()) - dist0.begin();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
towns.cpp:20:51: warning: conversion from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'} to 'int' may change value [-Wconversion]
20 | int b = max_element(dist.begin(), dist.end()) - dist.begin();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
towns.cpp:38:20: error: no matching function for call to 'begin(std::pair<const int, std::vector<int> >&)'
38 | for(auto z:h){
| ^
In file included from /usr/include/c++/10/bits/range_access.h:36,
from /usr/include/c++/10/string:54,
from /usr/include/c++/10/bits/locale_classes.h:40,
from /usr/include/c++/10/bits/ios_base.h:41,
from /usr/include/c++/10/ios:42,
from /usr/include/c++/10/istream:38,
from /usr/include/c++/10/sstream:38,
from /usr/include/c++/10/complex:45,
from /usr/include/c++/10/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
from towns.cpp:1:
/usr/include/c++/10/initializer_list:90:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>)'
90 | begin(initializer_list<_Tp> __ils) noexcept
| ^~~~~
/usr/include/c++/10/initializer_list:90:5: note: template argument deduction/substitution failed:
towns.cpp:38:20: note: 'std::pair<const int, std::vector<int> >' is not derived from 'std::initializer_list<_Tp>'
38 | for(auto z:h){
| ^
In file included from /usr/include/c++/10/string:54,
from /usr/include/c++/10/bits/locale_classes.h:40,
from /usr/include/c++/10/bits/ios_base.h:41,
from /usr/include/c++/10/ios:42,
from /usr/include/c++/10/istream:38,
from /usr/include/c++/10/sstream:38,
from /usr/include/c++/10/complex:45,
from /usr/include/c++/10/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
from towns.cpp:1:
/usr/include/c++/10/bits/range_access.h:51:5: note: candidate: 'template<class _Container> decltype (__cont.begin()) std::begin(_Container&)'
51 | begin(_Container& __cont) -> decltype(__cont.begin())
| ^~~~~
/usr/include/c++/10/bits/range_access.h:51:5: note: template argument deduction/substitution failed:
/usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.begin()) std::begin(_Container&) [with _Container = std::pair<const int, std::vector<int> >]':
towns.cpp:38:20: required from here
/usr/include/c++/10/bits/range_access.h:51:50: error: 'struct std::pair<const int, std::vector<int> >' has no member named 'begin'
51 | begin(_Container& __cont) -> decltype(__cont.begin())
| ~~~~~~~^~~~~
/usr/include/c++/10/bits/range_access.h:61:5: note: candidate: 'template<class _Container> decltype (__cont.begin()) std::begin(const _Container&)'
61 | begin(const _Container& __cont) -> decltype(__cont.begin())
| ^~~~~
/usr/include/c++/10/bits/range_access.h:61:5: note: template argument deduction/substitution failed:
/usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.begin()) std::begin(const _Container&) [with _Container = std::pair<const int, std::vector<int> >]':
towns.cpp:38:20: required from here
/usr/include/c++/10/bits/range_access.h:61:56: error: 'const struct std::pair<const int, std::vector<int> >' has no member named 'begin'
61 | begin(const _Container& __cont) -> decltype(__cont.begin())
| ~~~~~~~^~~~~
/usr/include/c++/10/bits/range_access.h:90:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::begin(_Tp (&)[_Nm])'
90 | begin(_Tp (&__arr)[_Nm])
| ^~~~~
/usr/include/c++/10/bits/range_access.h:90:5: note: template argument deduction/substitution failed:
towns.cpp:38:20: note: mismatched types '_Tp [_Nm]' and 'std::pair<const int, std::vector<int> >'
38 | for(auto z:h){
| ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
from towns.cpp:1:
/usr/include/c++/10/valarray:1214:5: note: candidate: 'template<class _Tp> _Tp* std::begin(std::valarray<_Tp>&)'
1214 | begin(valarray<_Tp>& __va)
| ^~~~~
/usr/include/c++/10/valarray:1214:5: note: template argument deduction/substitution failed:
towns.cpp:38:20: note: 'std::pair<const int, std::vector<int> >' is not derived from 'std::valarray<_Tp>'
38 | for(auto z:h){
| ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
from towns.cpp:1:
/usr/include/c++/10/valarray:1224:5: note: candidate: 'template<class _Tp> const _Tp* std::begin(const std::valarray<_Tp>&)'
1224 | begin(const valarray<_Tp>& __va)
| ^~~~~
/usr/include/c++/10/valarray:1224:5: note: template argument deduction/substitution failed:
towns.cpp:38:20: note: 'std::pair<const int, std::vector<int> >' is not derived from 'const std::valarray<_Tp>'
38 | for(auto z:h){
| ^
towns.cpp:38:20: error: no matching function for call to 'end(std::pair<const int, std::vector<int> >&)'
In file included from /usr/include/c++/10/bits/range_access.h:36,
from /usr/include/c++/10/string:54,
from /usr/include/c++/10/bits/locale_classes.h:40,
from /usr/include/c++/10/bits/ios_base.h:41,
from /usr/include/c++/10/ios:42,
from /usr/include/c++/10/istream:38,
from /usr/include/c++/10/sstream:38,
from /usr/include/c++/10/complex:45,
from /usr/include/c++/10/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
from towns.cpp:1:
/usr/include/c++/10/initializer_list:101:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)'
101 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
/usr/include/c++/10/initializer_list:101:5: note: template argument deduction/substitution failed:
towns.cpp:38:20: note: 'std::pair<const int, std::vector<int> >' is not derived from 'std::initializer_list<_Tp>'
38 | for(auto z:h){
| ^
In file included from /usr/include/c++/10/string:54,
from /usr/include/c++/10/bits/locale_classes.h:40,
from /usr/include/c++/10/bits/ios_base.h:41,
from /usr/include/c++/10/ios:42,
from /usr/include/c++/10/istream:38,
from /usr/include/c++/10/sstream:38,
from /usr/include/c++/10/complex:45,
from /usr/include/c++/10/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
from towns.cpp:1:
/usr/include/c++/10/bits/range_access.h:71:5: note: candidate: 'template<class _Container> decltype (__cont.end()) std::end(_Container&)'
71 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/10/bits/range_access.h:71:5: note: template argument deduction/substitution failed:
/usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.end()) std::end(_Container&) [with _Container = std::pair<const int, std::vector<int> >]':
towns.cpp:38:20: required from here
/usr/include/c++/10/bits/range_access.h:71:48: error: 'struct std::pair<const int, std::vector<int> >' has no member named 'end'
71 | end(_Container& __cont) -> decltype(__cont.end())
| ~~~~~~~^~~
/usr/include/c++/10/bits/range_access.h:81:5: note: candidate: 'template<class _Container> decltype (__cont.end()) std::end(const _Container&)'
81 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/10/bits/range_access.h:81:5: note: template argument deduction/substitution failed:
/usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.end()) std::end(const _Container&) [with _Container = std::pair<const int, std::vector<int> >]':
towns.cpp:38:20: required from here
/usr/include/c++/10/bits/range_access.h:81:54: error: 'const struct std::pair<const int, std::vector<int> >' has no member named 'end'
81 | end(const _Container& __cont) -> decltype(__cont.end())
| ~~~~~~~^~~
/usr/include/c++/10/bits/range_access.h:100:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
100 | end(_Tp (&__arr)[_Nm])
| ^~~
/usr/include/c++/10/bits/range_access.h:100:5: note: template argument deduction/substitution failed:
towns.cpp:38:20: note: mismatched types '_Tp [_Nm]' and 'std::pair<const int, std::vector<int> >'
38 | for(auto z:h){
| ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
from towns.cpp:1:
/usr/include/c++/10/valarray:1234:5: note: candidate: 'template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)'
1234 | end(valarray<_Tp>& __va)
| ^~~
/usr/include/c++/10/valarray:1234:5: note: template argument deduction/substitution failed:
towns.cpp:38:20: note: 'std::pair<const int, std::vector<int> >' is not derived from 'std::valarray<_Tp>'
38 | for(auto z:h){
| ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
from towns.cpp:1:
/usr/include/c++/10/valarray:1244:5: note: candidate: 'template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)'
1244 | end(const valarray<_Tp>& __va)
| ^~~
/usr/include/c++/10/valarray:1244:5: note: template argument deduction/substitution failed:
towns.cpp:38:20: note: 'std::pair<const int, std::vector<int> >' is not derived from 'const std::valarray<_Tp>'
38 | for(auto z:h){
| ^
towns.cpp:39:23: error: 'i' was not declared in this scope
39 | dis2[z]=f(i,z)-pos[i]+abs(mp,h.fs);
| ^
towns.cpp:39:21: error: 'f' was not declared in this scope
39 | dis2[z]=f(i,z)-pos[i]+abs(mp,h.fs);
| ^
towns.cpp:39:44: error: 'struct std::pair<const int, std::vector<int> >' has no member named 'fs'
39 | dis2[z]=f(i,z)-pos[i]+abs(mp,h.fs);
| ^~
towns.cpp:49:16: error: 'f' was not declared in this scope
49 | if(f(i,j)!=dis2[i]+dis2[j]){
| ^
towns.cpp:44:9: warning: unused variable 'cnt' [-Wunused-variable]
44 | int cnt=0,lo=0;
| ^~~
towns.cpp:44:15: warning: unused variable 'lo' [-Wunused-variable]
44 | int cnt=0,lo=0;
| ^~
towns.cpp:6:28: warning: unused parameter 'sub' [-Wunused-parameter]
6 | int hubDistance(int n, int sub) {
| ~~~~^~~