답안 #150300

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
150300 2019-09-01T08:05:29 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));
				continue;
			}

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

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

	return (long long)set_pair.count();
}

Compilation message

museum.cpp: In function 'long long int CountSimilarPairs(std::vector<int>, std::vector<int>, std::vector<int>)':
museum.cpp:33:35: error: no matching function for call to 'std::set<std::pair<int, int> >::count()'
  return (long long)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:33:35: note:   candidate expects 1 argument, 0 provided
  return (long long)set_pair.count();
                                   ^
museum.cpp:9:12: warning: unused variable 'count' [-Wunused-variable]
  long long count = 0;
            ^~~~~