답안 #150287

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
150287 2019-09-01T08:04:18 Z Outfraware Boat People(#3577, c4big, bsyo2k, cepiloth) 함수컵 박물관 (FXCUP4_museum) C++17
컴파일 오류
0 ms 0 KB
#include "museum.h"
#include <set>

typedef std::pair<int, int> PII;
typedef std::set<PII> SETPAIR;

long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
	int N = B.size();
	long long count = 0;

	SETPAIR set_pair;


	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			if (B[i] == B[j]) {
				set_pair.insert(PII(i, j));
			}

			if (T[i] == T[j]) {
				set_pair.insert(PII(i, j));
			}

			if (G[i] == G[j]) {
				set_pair.insert(PII(i, j));
			}
		}
	}

	return set_pair.count();
}

Compilation message

museum.cpp: In function 'long long int CountSimilarPairs(std::vector<int>, std::vector<int>, std::vector<int>)':
museum.cpp:30:24: error: no matching function for call to 'std::set<std::pair<int, int> >::count()'
  return set_pair.count();
                        ^
In file included from /usr/include/c++/7/set:61:0,
                 from museum.cpp:2:
/usr/include/c++/7/bits/stl_set.h:738:7: note: candidate: std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::count(const key_type&) const [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::size_type = long unsigned int; std::set<_Key, _Compare, _Alloc>::key_type = std::pair<int, int>]
       count(const key_type& __x) const
       ^~~~~
/usr/include/c++/7/bits/stl_set.h:738:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/7/bits/stl_set.h:744:2: note: candidate: template<class _Kt> decltype (((const std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_count_tr(__x)) std::set<_Key, _Compare, _Alloc>::count(const _Kt&) const [with _Kt = _Kt; _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]
  count(const _Kt& __x) const
  ^~~~~
/usr/include/c++/7/bits/stl_set.h:744:2: note:   template argument deduction/substitution failed:
museum.cpp:30:24: note:   candidate expects 1 argument, 0 provided
  return set_pair.count();
                        ^
museum.cpp:9:12: warning: unused variable 'count' [-Wunused-variable]
  long long count = 0;
            ^~~~~