답안 #685693

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
685693 2023-01-24T21:00:09 Z grossly_overconfident Fish (IOI08_fish) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"

int main() {
	int f, k, m;
	vector<pair<int, int>> fish;
	cin >> f >> k >> m;
	for (int i = 0; i < f; ++i) {
		int a, b;
		cin >> a >> b;
		fish.push_back(make_pair(a, b));
	}
	sort(fish.begin(), fish.end());
	set<set<int>> s;
	vector<set<int>> take;
	int current = fish[0].first;
	long long count;
	for (auto i : fish) {
		if (i.first != current) {
			for (auto p : take) {
				s.insert(p);
				++count;
				count %= m;
			}
			take = {};
		}
		for (auto k = s.begin(); k != s.end(); ++k) {
			auto j = *k;
			j.insert(i.second);
			if (take.count(j) == 0) {
				take.insert(j);
			}
		}
	}
	for (auto p : take) {
		s.insert(p);
		++count;
		count %= m;
	}
	cout << (count % m);



	return 0;
}

Compilation message

fish.cpp: In function 'int main()':
fish.cpp:32:13: error: 'class std::vector<std::set<int> >' has no member named 'count'
   32 |    if (take.count(j) == 0) {
      |             ^~~~~
fish.cpp:33:18: error: no matching function for call to 'std::vector<std::set<int> >::insert(std::set<int>&)'
   33 |     take.insert(j);
      |                  ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from fish.cpp:2:
/usr/include/c++/10/bits/vector.tcc:130:5: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, const value_type&) [with _Tp = std::set<int>; _Alloc = std::allocator<std::set<int> >; std::vector<_Tp, _Alloc>::iterator = std::vector<std::set<int> >::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<std::set<int> >::const_iterator; std::vector<_Tp, _Alloc>::value_type = std::set<int>]'
  130 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:130:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from fish.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1293:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::set<int>; _Alloc = std::allocator<std::set<int> >; std::vector<_Tp, _Alloc>::iterator = std::vector<std::set<int> >::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<std::set<int> >::const_iterator; std::vector<_Tp, _Alloc>::value_type = std::set<int>]'
 1293 |       insert(const_iterator __position, value_type&& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1293:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/stl_vector.h:1310:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::initializer_list<_Tp>) [with _Tp = std::set<int>; _Alloc = std::allocator<std::set<int> >; std::vector<_Tp, _Alloc>::iterator = std::vector<std::set<int> >::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<std::set<int> >::const_iterator]'
 1310 |       insert(const_iterator __position, initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1310:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/stl_vector.h:1335:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = std::set<int>; _Alloc = std::allocator<std::set<int> >; std::vector<_Tp, _Alloc>::iterator = std::vector<std::set<int> >::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<std::set<int> >::const_iterator; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = std::set<int>]'
 1335 |       insert(const_iterator __position, size_type __n, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1335:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/10/bits/stl_vector.h:1379:2: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, _InputIterator, _InputIterator) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = std::set<int>; _Alloc = std::allocator<std::set<int> >]'
 1379 |  insert(const_iterator __position, _InputIterator __first,
      |  ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1379:2: note:   template argument deduction/substitution failed:
fish.cpp:33:18: note:   candidate expects 3 arguments, 1 provided
   33 |     take.insert(j);
      |                  ^