Submission #1013166

# Submission time Handle Problem Language Result Execution time Memory
1013166 2024-07-03T09:02:25 Z vjudge1 timeismoney (balkan11_timeismoney) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<long long,long long>
#define f first
#define s second
using namespace std;
int mod = 1e9+7;
ll inf = 1e18+5;
int n,m,size[205],link[205],reza1,reza2;
vector<pair<pii,pii>> putovi;

int find(int a){
	if(link[a]==a)return a;
	return link[a] = find(link[a]);
}

bool same(int a,int b){
	return (find(a)==find(b));
}


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	for(int i = 0; i<205; i++){size[i]=1; link[i]=i;}	
	cin>>n>>m;
	for(int i = 0; i<m; i++){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		putovi.push_back({{c,d},{a,b}});
	}
	sort(putovi.begin(),putovi.end());
	for(auto z : putovi){
		int a = z.s.f;
		int b = z.s.s;
		if(same(a,b))continue;
		a = find(a);
		b = find(a);
		if(size[a]>size[b])swap(a,b);
		//size od a je manji od size od b
		size[b]+=size[a];
		link[a]=b;
		reza1+=z.f.f;
		reza2+=z.f.s;
	}

	cout<<reza1<<" "<<reza2<<endl;
return 0;
}

Compilation message

timeismoney.cpp: In function 'int main()':
timeismoney.cpp:26:29: error: reference to 'size' is ambiguous
   26 |  for(int i = 0; i<205; i++){size[i]=1; link[i]=i;}
      |                             ^~~~
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 timeismoney.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
timeismoney.cpp:10:9: note:                 'int size [205]'
   10 | int n,m,size[205],link[205],reza1,reza2;
      |         ^~~~
timeismoney.cpp:40:6: error: reference to 'size' is ambiguous
   40 |   if(size[a]>size[b])swap(a,b);
      |      ^~~~
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 timeismoney.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
timeismoney.cpp:10:9: note:                 'int size [205]'
   10 | int n,m,size[205],link[205],reza1,reza2;
      |         ^~~~
timeismoney.cpp:40:14: error: reference to 'size' is ambiguous
   40 |   if(size[a]>size[b])swap(a,b);
      |              ^~~~
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 timeismoney.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
timeismoney.cpp:10:9: note:                 'int size [205]'
   10 | int n,m,size[205],link[205],reza1,reza2;
      |         ^~~~
timeismoney.cpp:42:3: error: reference to 'size' is ambiguous
   42 |   size[b]+=size[a];
      |   ^~~~
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 timeismoney.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
timeismoney.cpp:10:9: note:                 'int size [205]'
   10 | int n,m,size[205],link[205],reza1,reza2;
      |         ^~~~
timeismoney.cpp:42:12: error: reference to 'size' is ambiguous
   42 |   size[b]+=size[a];
      |            ^~~~
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 timeismoney.cpp:1:
/usr/include/c++/10/bits/range_access.h:254:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  254 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/10/bits/range_access.h:245:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  245 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
timeismoney.cpp:10:9: note:                 'int size [205]'
   10 | int n,m,size[205],link[205],reza1,reza2;
      |         ^~~~