Submission #828965

# Submission time Handle Problem Language Result Execution time Memory
828965 2023-08-17T21:44:02 Z MohamedAhmed04 Meetings (JOI19_meetings) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "meetings.h"

using namespace std ;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) ;

int rand(int l , int r)
{
	return uniform_int_distribution<int>(l , r)(rng) ;
}

const int MAX = 2004 ;

int n ;

vector< pair<int , int> >ans ;

int mark[MAX] ;

void solve(int root , vector<int>v)
{
	if(!v.size())
		return ;
	shuffle(v.begin() , v.end() , rng) ;
	for(auto &node : v)
		mark[node] = 0 ;
	vector< vector<int> >subtrees = {{v.back()}} ;
	v.pop_back() ;
	for(auto &node : v)
	{
		if(mark[node])
			continue ;
		shuffle(subtrees.begin() , subtrees.end()) ;
		mark[node] = 1 ;
		bool flag = false ;
		for(auto &v2 : subtrees)
		{
			int lca = Query(root , node , v2.back()) ;
			if(lca == root)
				continue ;
			flag = true , mark[lca] = 1 ;
			v2.push_back(node) ;
			int sz = v2.size() ;
			if(lca != v2[sz-1])
				swap(v2[sz-1] , v2[sz-2]) ;
			if(lca != v2[sz-1])
				v2.push_back(lca) ;
			break ;
		}
		if(!flag)
			subtrees.push_back({node}) ;
	}
	for(auto &v2 : subtrees)
	{
		int root2 = v2.back() ;
		ans.emplace_back(min(root , root2) , max(root , root2)) ;
		v2.pop_back() ;
		solve(root2 , v2) ;
	}
}

void Solve(int N) 
{
	n = N ;
	int root = rand(0 , n-1) ;
	vector<int>v ;
	for(int i = 0 ; i < n ; ++i)
	{
		if(i != root)
			v.push_back(i) ;
	}
	solve(root , v) ;
	for(auto &p : ans)
		Bridge(p.first , p.second) ;
}

Compilation message

meetings.cpp: In function 'void solve(int, std::vector<int>)':
meetings.cpp:34:44: error: no matching function for call to 'shuffle(std::vector<std::vector<int> >::iterator, std::vector<std::vector<int> >::iterator)'
   34 |   shuffle(subtrees.begin() , subtrees.end()) ;
      |                                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from meetings.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3748:5: note: candidate: 'template<class _RAIter, class _UGenerator> void std::shuffle(_RAIter, _RAIter, _UGenerator&&)'
 3748 |     shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~~~~
/usr/include/c++/10/bits/stl_algo.h:3748:5: note:   template argument deduction/substitution failed:
meetings.cpp:34:44: note:   candidate expects 3 arguments, 2 provided
   34 |   shuffle(subtrees.begin() , subtrees.end()) ;
      |                                            ^