답안 #54892

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
54892 2018-07-05T09:07:22 Z 김세빈(#1509) Pipes (CEOI15_pipes) C++11
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

typedef pair<int,int> pii;

vector <int> V[101010];
int P[101010], K[101010];
int R[101010], D[101010], S[101010];
bool chk[101010];
int n, m;

void reorder(int x, int p, int r, int f)
{
	int i, c;
	
	D[p] = D[r] + 1; R[p] = x;
	c = K[p], K[p] = r;
	
	if(c != r) swap(f, chk[p]);
	
	if(chk[p]) P[p] = P[r];
	else P[p] = r;
	
	for(auto t: V[p]){
		if(t != r){
			if(t == c) reorder(x, t, p, f);
			else reorder(x, t, p, 0);
		}
	}
}

int color(int a, int b)
{
	if(a == b) return a;
	if(D[a] > D[b]) chk[a] = 1, P[a] = color(P[a], b);
	else chk[b] = 1, P[b] = color(a, P[b]);
}

int main()
{
	int i, a, b;
	
	scanf("%d%d", &n, &m);
	
	for(i=1;i<=n;i++){
		S[i] = 1;
		R[i] = i;
	}
	
	for(i=1;i<=m;i++){
		scanf("%d%d", &a, &b);
		if(R[a] != R[b]){
			if(S[R[a]] > S[R[b]]) swap(a, b);
			
			V[a].push_back(b);
			V[b].push_back(a);
			
			S[R[b]] += S[R[a]];
			reorder(R[b], a, b, 0);
		}
		else color(a, b);
	}
	
	for(i=1;i<=n;i++){
		if(R[i] != i && !chk[i]) printf("%d %d\n", i, K[i]);
	}
	
	return 0;
}

Compilation message

pipes.cpp: In function 'void reorder(int, int, int, int)':
pipes.cpp:20:27: error: no matching function for call to 'swap(int&, bool&)'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/c++/7/complex:45:0,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from pipes.cpp:1:
/usr/include/c++/7/sstream:796:5: note: candidate: template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>&)
     swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x,
     ^~~~
/usr/include/c++/7/sstream:796:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/c++/7/complex:45:0,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from pipes.cpp:1:
/usr/include/c++/7/sstream:803:5: note: candidate: template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(std::__cxx11::basic_istringstream<_CharT, _Traits, _Allocator>&, std::__cxx11::basic_istringstream<_CharT, _Traits, _Allocator>&)
     swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x,
     ^~~~
/usr/include/c++/7/sstream:803:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::__cxx11::basic_istringstream<_CharT, _Traits, _Allocator>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/c++/7/complex:45:0,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from pipes.cpp:1:
/usr/include/c++/7/sstream:810:5: note: candidate: template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(std::__cxx11::basic_ostringstream<_CharT, _Traits, _Allocator>&, std::__cxx11::basic_ostringstream<_CharT, _Traits, _Allocator>&)
     swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x,
     ^~~~
/usr/include/c++/7/sstream:810:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::__cxx11::basic_ostringstream<_CharT, _Traits, _Allocator>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/c++/7/complex:45:0,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from pipes.cpp:1:
/usr/include/c++/7/sstream:817:5: note: candidate: template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(std::__cxx11::basic_stringstream<_CharT, _Traits, _Allocator>&, std::__cxx11::basic_stringstream<_CharT, _Traits, _Allocator>&)
     swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x,
     ^~~~
/usr/include/c++/7/sstream:817:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::__cxx11::basic_stringstream<_CharT, _Traits, _Allocator>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/c++/7/regex:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110,
                 from pipes.cpp:1:
/usr/include/c++/7/bits/regex.h:805:5: note: candidate: template<class _Ch_type, class _Rx_traits> void std::__cxx11::swap(std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&, std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&)
     swap(basic_regex<_Ch_type, _Rx_traits>& __lhs,
     ^~~~
/usr/include/c++/7/bits/regex.h:805:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::__cxx11::basic_regex<_Ch_type, _Rx_traits>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/c++/7/regex:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110,
                 from pipes.cpp:1:
/usr/include/c++/7/bits/regex.h:1958:5: note: candidate: template<class _Bi_iter, class _Alloc> void std::__cxx11::swap(std::__cxx11::match_results<_BiIter, _Alloc>&, std::__cxx11::match_results<_BiIter, _Alloc>&)
     swap(match_results<_Bi_iter, _Alloc>& __lhs,
     ^~~~
/usr/include/c++/7/bits/regex.h:1958:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::__cxx11::match_results<_BiIter, _Alloc>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/c++/7/unordered_set:48:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:118,
                 from pipes.cpp:1:
/usr/include/c++/7/bits/unordered_set.h:1528:5: note: candidate: template<class _Value, class _Hash, class _Pred, class _Alloc> void std::swap(std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>&, std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>&)
     swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
     ^~~~
/usr/include/c++/7/bits/unordered_set.h:1528:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/c++/7/unordered_set:48:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:118,
                 from pipes.cpp:1:
/usr/include/c++/7/bits/unordered_set.h:1521:5: note: candidate: template<class _Value, class _Hash, class _Pred, class _Alloc> void std::swap(std::unordered_set<_Value, _Hash, _Pred, _Alloc>&, std::unordered_set<_Value, _Hash, _Pred, _Alloc>&)
     swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
     ^~~~
/usr/include/c++/7/bits/unordered_set.h:1521:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::unordered_set<_Value, _Hash, _Pred, _Alloc>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/c++/7/unordered_map:48:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:117,
                 from pipes.cpp:1:
/usr/include/c++/7/bits/unordered_map.h:1904:5: note: candidate: template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> void std::swap(std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&, std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&)
     swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
     ^~~~
/usr/include/c++/7/bits/unordered_map.h:1904:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/c++/7/unordered_map:48:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:117,
                 from pipes.cpp:1:
/usr/include/c++/7/bits/unordered_map.h:1897:5: note: candidate: template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> void std::swap(std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&, std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&)
     swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
     ^~~~
/usr/include/c++/7/bits/unordered_map.h:1897:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:105:0,
                 from pipes.cpp:1:
/usr/include/c++/7/future:1579:5: note: candidate: template<class _Res, class ... _ArgTypes> void std::swap(std::packaged_task<_Res(_ArgTypes ...)>&, std::packaged_task<_Res(_ArgTypes ...)>&)
     swap(packaged_task<_Res(_ArgTypes...)>& __x,
     ^~~~
/usr/include/c++/7/future:1579:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::packaged_task<_Res(_ArgTypes ...)>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:105:0,
                 from pipes.cpp:1:
/usr/include/c++/7/future:1144:5: note: candidate: template<class _Res> void std::swap(std::promise<_Res>&, std::promise<_Res>&)
     swap(promise<_Res>& __x, promise<_Res>& __y) noexcept
     ^~~~
/usr/include/c++/7/future:1144:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::promise<_Res>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/c++/7/future:39:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:105,
                 from pipes.cpp:1:
/usr/include/c++/7/thread:263:3: note: candidate: void std::swap(std::thread&, std::thread&)
   swap(thread& __x, thread& __y) noexcept
   ^~~~
/usr/include/c++/7/thread:263:3: note:   no known conversion for argument 1 from 'int' to 'std::thread&'
In file included from /usr/include/c++/7/forward_list:38:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:104,
                 from pipes.cpp:1:
/usr/include/c++/7/bits/forward_list.h:1427:5: note: candidate: template<class _Tp, class _Alloc> void std::swap(std::forward_list<_Tp, _Alloc>&, std::forward_list<_Tp, _Alloc>&)
     swap(forward_list<_Tp, _Alloc>& __lx,
     ^~~~
/usr/include/c++/7/bits/forward_list.h:1427:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::forward_list<_Tp, _Alloc>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/c++/7/condition_variable:39:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:103,
                 from pipes.cpp:1:
/usr/include/c++/7/bits/std_mutex.h:363:5: note: candidate: template<class _Mutex> void std::swap(std::unique_lock<_Mutex>&, std::unique_lock<_Mutex>&)
     swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y) noexcept
     ^~~~
/usr/include/c++/7/bits/std_mutex.h:363:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::unique_lock<_Mutex>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/c++/7/stack:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:89,
                 from pipes.cpp:1:
/usr/include/c++/7/bits/stl_stack.h:347:5: note: candidate: template<class _Tp, class _Seq> void std::swap(std::stack<_Tp, _Seq>&, std::stack<_Tp, _Seq>&)
     swap(stack<_Tp, _Seq>& __x, stack<_Tp, _Seq>& __y)
     ^~~~
/usr/include/c++/7/bits/stl_stack.h:347:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::stack<_Tp, _Seq>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/c++/7/set:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from pipes.cpp:1:
/usr/include/c++/7/bits/stl_multiset.h:948:5: note: candidate: template<class _Key, class _Compare, class _Alloc> void std::swap(std::multiset<_Key, _Compare, _Alloc>&, std::multiset<_Key, _Compare, _Alloc>&)
     swap(multiset<_Key, _Compare, _Alloc>& __x,
     ^~~~
/usr/include/c++/7/bits/stl_multiset.h:948:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::multiset<_Key, _Compare, _Alloc>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from pipes.cpp:1:
/usr/include/c++/7/bits/stl_set.h:965:5: note: candidate: template<class _Key, class _Compare, class _Alloc> void std::swap(std::set<_Key, _Compare, _Alloc>&, std::set<_Key, _Compare, _Alloc>&)
     swap(set<_Key, _Compare, _Alloc>& __x, set<_Key, _Compare, _Alloc>& __y)
     ^~~~
/usr/include/c++/7/bits/stl_set.h:965:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::set<_Key, _Compare, _Alloc>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from pipes.cpp:1:
/usr/include/c++/7/bits/stl_queue.h:668:5: note: candidate: template<class _Tp, class _Sequence, class _Compare> void std::swap(std::priority_queue<_Tp, _Sequence, _Compare>&, std::priority_queue<_Tp, _Sequence, _Compare>&)
     swap(priority_queue<_Tp, _Sequence, _Compare>& __x,
     ^~~~
/usr/include/c++/7/bits/stl_queue.h:668:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::priority_queue<_Tp, _Sequence, _Compare>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from pipes.cpp:1:
/usr/include/c++/7/bits/stl_queue.h:372:5: note: candidate: template<class _Tp, class _Seq> void std::swap(std::queue<_Tp, _Seq>&, std::queue<_Tp, _Seq>&)
     swap(queue<_Tp, _Seq>& __x, queue<_Tp, _Seq>& __y)
     ^~~~
/usr/include/c++/7/bits/stl_queue.h:372:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::queue<_Tp, _Seq>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/c++/7/vector:65:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from pipes.cpp:1:
/usr/include/c++/7/bits/stl_bvector.h:128:3: note: candidate: void std::swap(bool&, std::_Bit_reference)
   swap(bool& __x, _Bit_reference __y) noexcept
   ^~~~
/usr/include/c++/7/bits/stl_bvector.h:128:3: note:   no known conversion for argument 2 from 'bool' to 'std::_Bit_reference'
/usr/include/c++/7/bits/stl_bvector.h:120:3: note: candidate: void std::swap(std::_Bit_reference, bool&)
   swap(_Bit_reference __x, bool& __y) noexcept
   ^~~~
/usr/include/c++/7/bits/stl_bvector.h:120:3: note:   no known conversion for argument 1 from 'int' to 'std::_Bit_reference'
/usr/include/c++/7/bits/stl_bvector.h:112:3: note: candidate: void std::swap(std::_Bit_reference, std::_Bit_reference)
   swap(_Bit_reference __x, _Bit_reference __y) noexcept
   ^~~~
/usr/include/c++/7/bits/stl_bvector.h:112:3: note:   no known conversion for argument 1 from 'int' to 'std::_Bit_reference'
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from pipes.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:1644:5: note: candidate: template<class _Tp, class _Alloc> void std::swap(std::vector<_Tp, _Alloc>&, std::vector<_Tp, _Alloc>&)
     swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y)
     ^~~~
/usr/include/c++/7/bits/stl_vector.h:1644:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::vector<_Tp, _Alloc>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/c++/7/memory:81:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:82,
                 from pipes.cpp:1:
/usr/include/c++/7/bits/shared_ptr.h:595:5: note: candidate: template<class _Tp> void std::swap(std::weak_ptr<_Tp>&, std::weak_ptr<_Tp>&)
     swap(weak_ptr<_Tp>& __a, weak_ptr<_Tp>& __b) noexcept
     ^~~~
/usr/include/c++/7/bits/shared_ptr.h:595:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::weak_ptr<_Tp>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/c++/7/memory:81:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:82,
                 from pipes.cpp:1:
/usr/include/c++/7/bits/shared_ptr.h:474:5: note: candidate: template<class _Tp> void std::swap(std::shared_ptr<_Tp>&, std::shared_ptr<_Tp>&)
     swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b) noexcept
     ^~~~
/usr/include/c++/7/bits/shared_ptr.h:474:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::shared_ptr<_Tp>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/c++/7/bits/shared_ptr.h:52:0,
                 from /usr/include/c++/7/memory:81,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:82,
                 from pipes.cpp:1:
/usr/include/c++/7/bits/shared_ptr_base.h:1741:5: note: candidate: template<class _Tp, __gnu_cxx::_Lock_policy _Lp> void std::swap(std::__weak_ptr<_Tp, _Lp>&, std::__weak_ptr<_Tp, _Lp>&)
     swap(__weak_ptr<_Tp, _Lp>& __a, __weak_ptr<_Tp, _Lp>& __b) noexcept
     ^~~~
/usr/include/c++/7/bits/shared_ptr_base.h:1741:5: note:   template argument deduction/substitution failed:
pipes.cpp:20:27: note:   mismatched types 'std::__weak_ptr<_Tp, _Lp>' and 'int'
  if(c != r) swap(f, chk[p]);
                           ^
In file included from /usr/include/c++/7/bits/shared_ptr.h:52:0,
                 from /usr/include/c++/7/memory:81,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:82,
                 from pipes.cpp:1:
/usr/include/c++/7/bits/shared_ptr_base.h:1533:5: note: candidate: template<class _Tp, __gnu_cxx::_Lock_policy _Lp> void std::swap(std::__shared_ptr<_Tp, _Lp>&, std::__shared_ptr<_Tp, _Lp>&)
     swap(__shared_ptr<_Tp, _Lp>& __a, __shared_ptr<_Tp, _Lp>& __b) noexcept
     ^~~~
/usr/include/c++/7/bits/shared_ptr_base.h:1533:5: note:   template argument deduction/substitution failed:
/var/local/