Submission #1011370

# Submission time Handle Problem Language Result Execution time Memory
1011370 2024-06-30T12:33:17 Z Double_Slash Languages (IOI10_languages) C++17
Compilation error
0 ms 0 KB
#include "lang.h"
#include "grader.h"
#include <bits/extc++.h>
 
using namespace std;
using namespace __gnu_pbds;
#define debug(x) [&] { auto _x = x; cerr << __LINE__ << ": " << #x << " = " << _x << endl; return _x; }()
using ll = long long;
using pint = pair<int, int>;

struct phash {
    ll operator()(const pint &x) const { return x.first << 16 | x.second; }
};
 
double magic(double x) {
	return pow(abs(x), 1.2);
}
 
template <typename T, class Hash>
struct Data : gp_hash_table<T, int, Hash> {
	int tot = 0;

	double operator&(Data<T, Hash> &o) const {
		double ret = 0;
		for (auto [k, v]: *this) {
			ret += magic((double) v / tot - (o.contains(k) ? (double) o.at(k) / o.tot : 0));
		}
		for (auto [k, v]: o) {
			if (not this->contains(k)) ret += magic((double) v / o.tot);
		}
		return ret;
	}
 
	void operator+=(Data<T, Hash> &o) {
		for (auto &[k, v]: o) {
			(*this)[k] += v;
		}
		tot += o.tot;
	}};
 
struct Profile {
	Data<int, hash<int>> sing;
  Data<pint, phash> doub;
 
	Profile() {}
 
	Profile(int *arr) {
		for (int i = 0; i < 100; ++i) {
			sing[arr[i]]++;
          if (i) doub[{arr[i - 1], arr[i]}]++;
		}
		sing.tot = 100;
      doub.tot = 99;
	}
 
	double operator&(Profile &o) const {
		return (sing & o.sing) + (doub & o.doub);
	}
 
	void operator+=(Profile &o) {
		sing += o.sing;
      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 'double Data<T, Hash>::operator&(Data<T, Hash>&) const [with T = int; Hash = std::hash<int>]':
lang.cpp:57:20:   required from here
lang.cpp:26:39: error: 'struct Data<int, std::hash<int> >' has no member named 'contains'
   26 |    ret += magic((double) v / tot - (o.contains(k) ? (double) o.at(k) / o.tot : 0));
      |                                     ~~^~~~~~~~
lang.cpp:26:64: error: 'struct Data<int, std::hash<int> >' has no member named 'at'
   26 |    ret += magic((double) v / tot - (o.contains(k) ? (double) o.at(k) / o.tot : 0));
      |                                                              ~~^~
lang.cpp:29:18: error: 'const struct Data<int, std::hash<int> >' has no member named 'contains'
   29 |    if (not this->contains(k)) ret += magic((double) v / o.tot);
      |            ~~~~~~^~~~~~~~
lang.cpp: In instantiation of 'double Data<T, Hash>::operator&(Data<T, Hash>&) const [with T = std::pair<int, int>; Hash = phash]':
lang.cpp:57:38:   required from here
lang.cpp:26:39: error: 'struct Data<std::pair<int, int>, phash>' has no member named 'contains'
   26 |    ret += magic((double) v / tot - (o.contains(k) ? (double) o.at(k) / o.tot : 0));
      |                                     ~~^~~~~~~~
lang.cpp:26:64: error: 'struct Data<std::pair<int, int>, phash>' has no member named 'at'
   26 |    ret += magic((double) v / tot - (o.contains(k) ? (double) o.at(k) / o.tot : 0));
      |                                                              ~~^~
lang.cpp:29:18: error: 'const struct Data<std::pair<int, int>, phash>' has no member named 'contains'
   29 |    if (not this->contains(k)) ret += magic((double) v / o.tot);
      |            ~~~~~~^~~~~~~~