답안 #1011385

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1011385 2024-06-30T12:51:51 Z Double_Slash Languages (IOI10_languages) C++17
컴파일 오류
0 ms 0 KB
#include "lang.h"
#include "grader.h"
#include <bits/stdc++.h>
 
using namespace std;
#define debug(x) [&] { auto _x = x; cerr << __LINE__ << ": " << #x << " = " << _x << endl; return _x; }()
using pint = pair<int, int>;

const int MAX = 100;
 
double magic(double x) {
	return pow(abs(x), 1.2);
}
 
template <typename T>
struct Data : map<T, int> {
	int tot = 0;
  set<pair<int, T>> inv;
 
	double operator&(const Data<T> &o) const {
		double ret = 0;
		for (auto [k, v]: *this) {
			ret += magic((double) v / tot - (o.count(k) ? (double) o.at(k) / o.tot : 0));
		}
		for (auto [k, v]: o) {
			if (not this->count(k)) ret += magic((double) v / o.tot);
		}
		return ret;
	}
 
	void operator+=(const Data<T> &o) {
		for (auto &[k, v]: o) {
          inv.erase({v, (*this)[k]});
			inv.emplace(v, (*this)[k] += v);
		}
		tot += o.tot;
      while (inv.size() > MAX) {
          tot -= inv.begin()->first;
          this->erase(inv.begin()->second);
}
	}};
 
struct Profile {
  Data<pint> doub;
 
	Profile() {}
 
	Profile(int *arr) {
		for (int i = 0; i < 100; ++i) {
          if (i) doub[{arr[i - 1], arr[i]}]++;
		}
      for (auto [k, v]: doub) doub.inv.emplace(v, k);
      doub.tot = 99;
	}
 
	double operator&(const Profile &o) const {
		return (doub & o.doub);
	}
 
	void operator+=(const Profile &o) {
      doub += o.doub;
	}
} profile[56];
 
void excerpt(int *E) {
	Profile p(E);
	pair<double, int> mn{1e18, 0};
	for (int i = 0; i < 56; ++i) {
		mn = min(mn, {p & profile[i], i});
	}
	int ans = language(mn.second);
	profile[ans] += p;
}

Compilation message

lang.cpp: In instantiation of 'void Data<T>::operator+=(const Data<T>&) [with T = std::pair<int, int>]':
lang.cpp:61:17:   required from here
lang.cpp:33:20: error: no matching function for call to 'std::set<std::pair<int, std::pair<int, int> >, std::less<std::pair<int, std::pair<int, int> > >, std::allocator<std::pair<int, std::pair<int, int> > > >::erase(<brace-enclosed initializer list>)'
   33 |           inv.erase({v, (*this)[k]});
      |           ~~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from lang.cpp:3:
/usr/include/c++/10/bits/stl_set.h:654:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(std::set<_Key, _Compare, _Alloc>::const_iterator) [with _Key = std::pair<int, std::pair<int, int> >; _Compare = std::less<std::pair<int, std::pair<int, int> > >; _Alloc = std::allocator<std::pair<int, std::pair<int, int> > >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, std::pair<int, int> >, std::pair<int, std::pair<int, int> >, std::_Identity<std::pair<int, std::pair<int, int> > >, std::less<std::pair<int, std::pair<int, int> > >, std::allocator<std::pair<int, std::pair<int, int> > > >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, std::pair<int, int> >, std::pair<int, std::pair<int, int> >, std::_Identity<std::pair<int, std::pair<int, int> > >, std::less<std::pair<int, std::pair<int, int> > >, std::allocator<std::pair<int, std::pair<int, int> > > >::const_iterator]'
  654 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/10/bits/stl_set.h:654:28: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::set<std::pair<int, std::pair<int, int> >, std::less<std::pair<int, std::pair<int, int> > >, std::allocator<std::pair<int, std::pair<int, int> > > >::const_iterator' {aka 'std::_Rb_tree<std::pair<int, std::pair<int, int> >, std::pair<int, std::pair<int, int> >, std::_Identity<std::pair<int, std::pair<int, int> > >, std::less<std::pair<int, std::pair<int, int> > >, std::allocator<std::pair<int, std::pair<int, int> > > >::const_iterator'}
  654 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/10/bits/stl_set.h:684:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::erase(const key_type&) [with _Key = std::pair<int, std::pair<int, int> >; _Compare = std::less<std::pair<int, std::pair<int, int> > >; _Alloc = std::allocator<std::pair<int, std::pair<int, int> > >; std::set<_Key, _Compare, _Alloc>::size_type = long unsigned int; std::set<_Key, _Compare, _Alloc>::key_type = std::pair<int, std::pair<int, int> >]'
  684 |       erase(const key_type& __x)
      |       ^~~~~
/usr/include/c++/10/bits/stl_set.h:684:29: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const std::pair<int, std::pair<int, int> >&'}
  684 |       erase(const key_type& __x)
      |             ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_set.h:706:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(std::set<_Key, _Compare, _Alloc>::const_iterator, std::set<_Key, _Compare, _Alloc>::const_iterator) [with _Key = std::pair<int, std::pair<int, int> >; _Compare = std::less<std::pair<int, std::pair<int, int> > >; _Alloc = std::allocator<std::pair<int, std::pair<int, int> > >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, std::pair<int, int> >, std::pair<int, std::pair<int, int> >, std::_Identity<std::pair<int, std::pair<int, int> > >, std::less<std::pair<int, std::pair<int, int> > >, std::allocator<std::pair<int, std::pair<int, int> > > >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, std::pair<int, int> >, std::pair<int, std::pair<int, int> >, std::_Identity<std::pair<int, std::pair<int, int> > >, std::less<std::pair<int, std::pair<int, int> > >, std::allocator<std::pair<int, std::pair<int, int> > > >::const_iterator]'
  706 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/10/bits/stl_set.h:706:7: note:   candidate expects 2 arguments, 1 provided