답안 #1011448

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1011448 2024-06-30T13:51:38 Z Double_Slash Languages (IOI10_languages) C++17
컴파일 오류
0 ms 0 KB
#include "lang.h"
#include "grader.h"
#include <bits/extc++.h>
 
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pint = pair<int, int>;
 
double magic(double x) {
	return abs(x);
}

template <typename T, class Hash, int MAX>
struct Data {
	int tot = 0;
    gp_hash_table<T, int, Hash> m;
  set<pair<int, T>> inv;
 
	double operator&(const Data<T, Hash, MAX> &o) const {
		double ret = 0;
		for (auto [k, v]: m) {
			ret += magic((double) v / tot - (o.m.count(k) ? (double) o.m.at(k) / o.tot : 0));
		}
		for (auto [k, v]: o.m) {
			if (not m.count(k)) ret += magic((double) v / o.tot);
		}
		return ret;
	}
 
	void operator+=(const Data<T, Hash, MAX> &o) {
		for (auto &[k, v]: o.m) {
          inv.erase({m[k], k});
			inv.emplace(m[k] += v, k);
		}
		tot += o.tot;
      while (inv.size() > MAX) {
          tot -= inv.begin()->first;
          m.erase(inv.begin()->second);
        inv.erase(inv.begin());
}
	}};

struct hash2 {
ll operator() (const pint &x) const { return (ll) x.first << 16 | x.second; }
};
struct hash3 {
ll operator()(const array<int, 3> &x) const { return ((ll) x[0] << 32) | ((ll) x[1] << 16) | x[2]; }
};
 
struct Profile {
Data<int, hash<int>, 100> sing;
  Data<pint, hash2, 100> doub;
  Data<array<int, 3>, hash3, 100> trip;
 
	Profile() {}
 
	Profile(int *arr) {
		for (int i = 0; i < 100; ++i) {
          sing.m[arr[i]]++;
          if (i) doub.m[{arr[i - 1], arr[i]}]++;
          if (i >=2) trip.m[{arr[i - 2], arr[i - 1], arr[i]}];
		}
      for (auto [k, v]: sing.m) sing.inv.emplace(v, k);
      for (auto [k, v]: doub.m) doub.inv.emplace(v, k);
            for (auto [k, v]: trip.m) trip.inv.emplace(v, k);
      
      sing.tot = 100;
      doub.tot = 99;
      trip.tot = 98;
	}
 
	double operator&(const Profile &o) const {
		return (sing & o.sing) + (doub & o.doub) + (trip & o.trip);
	}
 
	void operator+=(const Profile &o) {
      sing += o.sing;
doub += o.doub;
      trip += o.trip;
	}
} 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, MAX>::operator&(const Data<T, Hash, MAX>&) const [with T = int; Hash = std::hash<int>; int MAX = 100]':
lang.cpp:74:20:   required from here
lang.cpp:23:41: error: 'const class __gnu_pbds::gp_hash_table<int, int, std::hash<int>, std::equal_to<int>, __gnu_pbds::direct_mask_range_hashing<>, __gnu_pbds::linear_probe_fn<long unsigned int>, __gnu_pbds::hash_standard_resize_policy<__gnu_pbds::hash_exponential_size_policy<>, __gnu_pbds::hash_load_check_resize_trigger<>, false, long unsigned int>, false, std::allocator<char> >' has no member named 'count'
   23 |    ret += magic((double) v / tot - (o.m.count(k) ? (double) o.m.at(k) / o.tot : 0));
      |                                     ~~~~^~~~~
lang.cpp:23:65: error: 'const class __gnu_pbds::gp_hash_table<int, int, std::hash<int>, std::equal_to<int>, __gnu_pbds::direct_mask_range_hashing<>, __gnu_pbds::linear_probe_fn<long unsigned int>, __gnu_pbds::hash_standard_resize_policy<__gnu_pbds::hash_exponential_size_policy<>, __gnu_pbds::hash_load_check_resize_trigger<>, false, long unsigned int>, false, std::allocator<char> >' has no member named 'at'
   23 |    ret += magic((double) v / tot - (o.m.count(k) ? (double) o.m.at(k) / o.tot : 0));
      |                                                             ~~~~^~
lang.cpp:26:14: error: 'const class __gnu_pbds::gp_hash_table<int, int, std::hash<int>, std::equal_to<int>, __gnu_pbds::direct_mask_range_hashing<>, __gnu_pbds::linear_probe_fn<long unsigned int>, __gnu_pbds::hash_standard_resize_policy<__gnu_pbds::hash_exponential_size_policy<>, __gnu_pbds::hash_load_check_resize_trigger<>, false, long unsigned int>, false, std::allocator<char> >' has no member named 'count'
   26 |    if (not m.count(k)) ret += magic((double) v / o.tot);
      |            ~~^~~~~
lang.cpp: In instantiation of 'double Data<T, Hash, MAX>::operator&(const Data<T, Hash, MAX>&) const [with T = std::pair<int, int>; Hash = hash2; int MAX = 100]':
lang.cpp:74:38:   required from here
lang.cpp:23:41: error: 'const class __gnu_pbds::gp_hash_table<std::pair<int, int>, int, hash2, std::equal_to<std::pair<int, int> >, __gnu_pbds::direct_mask_range_hashing<>, __gnu_pbds::linear_probe_fn<long unsigned int>, __gnu_pbds::hash_standard_resize_policy<__gnu_pbds::hash_exponential_size_policy<>, __gnu_pbds::hash_load_check_resize_trigger<>, false, long unsigned int>, false, std::allocator<char> >' has no member named 'count'
   23 |    ret += magic((double) v / tot - (o.m.count(k) ? (double) o.m.at(k) / o.tot : 0));
      |                                     ~~~~^~~~~
lang.cpp:23:65: error: 'const class __gnu_pbds::gp_hash_table<std::pair<int, int>, int, hash2, std::equal_to<std::pair<int, int> >, __gnu_pbds::direct_mask_range_hashing<>, __gnu_pbds::linear_probe_fn<long unsigned int>, __gnu_pbds::hash_standard_resize_policy<__gnu_pbds::hash_exponential_size_policy<>, __gnu_pbds::hash_load_check_resize_trigger<>, false, long unsigned int>, false, std::allocator<char> >' has no member named 'at'
   23 |    ret += magic((double) v / tot - (o.m.count(k) ? (double) o.m.at(k) / o.tot : 0));
      |                                                             ~~~~^~
lang.cpp:26:14: error: 'const class __gnu_pbds::gp_hash_table<std::pair<int, int>, int, hash2, std::equal_to<std::pair<int, int> >, __gnu_pbds::direct_mask_range_hashing<>, __gnu_pbds::linear_probe_fn<long unsigned int>, __gnu_pbds::hash_standard_resize_policy<__gnu_pbds::hash_exponential_size_policy<>, __gnu_pbds::hash_load_check_resize_trigger<>, false, long unsigned int>, false, std::allocator<char> >' has no member named 'count'
   26 |    if (not m.count(k)) ret += magic((double) v / o.tot);
      |            ~~^~~~~
lang.cpp: In instantiation of 'double Data<T, Hash, MAX>::operator&(const Data<T, Hash, MAX>&) const [with T = std::array<int, 3>; Hash = hash3; int MAX = 100]':
lang.cpp:74:56:   required from here
lang.cpp:23:41: error: 'const class __gnu_pbds::gp_hash_table<std::array<int, 3>, int, hash3, std::equal_to<std::array<int, 3> >, __gnu_pbds::direct_mask_range_hashing<>, __gnu_pbds::linear_probe_fn<long unsigned int>, __gnu_pbds::hash_standard_resize_policy<__gnu_pbds::hash_exponential_size_policy<>, __gnu_pbds::hash_load_check_resize_trigger<>, false, long unsigned int>, false, std::allocator<char> >' has no member named 'count'
   23 |    ret += magic((double) v / tot - (o.m.count(k) ? (double) o.m.at(k) / o.tot : 0));
      |                                     ~~~~^~~~~
lang.cpp:23:65: error: 'const class __gnu_pbds::gp_hash_table<std::array<int, 3>, int, hash3, std::equal_to<std::array<int, 3> >, __gnu_pbds::direct_mask_range_hashing<>, __gnu_pbds::linear_probe_fn<long unsigned int>, __gnu_pbds::hash_standard_resize_policy<__gnu_pbds::hash_exponential_size_policy<>, __gnu_pbds::hash_load_check_resize_trigger<>, false, long unsigned int>, false, std::allocator<char> >' has no member named 'at'
   23 |    ret += magic((double) v / tot - (o.m.count(k) ? (double) o.m.at(k) / o.tot : 0));
      |                                                             ~~~~^~
lang.cpp:26:14: error: 'const class __gnu_pbds::gp_hash_table<std::array<int, 3>, int, hash3, std::equal_to<std::array<int, 3> >, __gnu_pbds::direct_mask_range_hashing<>, __gnu_pbds::linear_probe_fn<long unsigned int>, __gnu_pbds::hash_standard_resize_policy<__gnu_pbds::hash_exponential_size_policy<>, __gnu_pbds::hash_load_check_resize_trigger<>, false, long unsigned int>, false, std::allocator<char> >' has no member named 'count'
   26 |    if (not m.count(k)) ret += magic((double) v / o.tot);
      |            ~~^~~~~