Submission #1011410

# Submission time Handle Problem Language Result Execution time Memory
1011410 2024-06-30T13:17:30 Z Double_Slash Languages (IOI10_languages) C++17
0 / 100
1657 ms 4688 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>;
 
double magic(double x) {
	return pow(abs(x), 1.2);
}
 
template <typename T>
struct Data : map<T, int> {
	int tot = 0, mx;
  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({(*this)[k], k});
			inv.emplace((*this)[k] += v, k);
		}
		tot += o.tot;
      while (inv.size() > mx) {
          tot -= inv.begin()->first;
          this->erase(inv.begin()->second);
        inv.erase(inv.begin());
}
	}};
 
struct Profile {
Data<int> sing;
  Data<pint> doub;
 
	Profile() {}
 
	Profile(int *arr) {
      sing.mx = 50;
      doub.mx = 100;
		for (int i = 0; i < 100; ++i) {
          sing[arr[i]]++;
          if (i) doub[{arr[i - 1], arr[i]}]++;
		}
      for (auto [k, v]: doub) doub.inv.emplace(v, k);
      sing.tot = 100;
      doub.tot = 99;
	}
 
	double operator&(const Profile &o) const {
		return (sing & o.sing) + (doub & o.doub);
	}
 
	void operator+=(const 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 'void Data<T>::operator+=(const Data<T>&) [with T = int]':
lang.cpp:65:17:   required from here
lang.cpp:35:25: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<int, int>, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |       while (inv.size() > mx) {
      |              ~~~~~~~~~~~^~~~
lang.cpp: In instantiation of 'void Data<T>::operator+=(const Data<T>&) [with T = std::pair<int, int>]':
lang.cpp:66:11:   required from here
lang.cpp:35:25: warning: comparison of integer expressions of different signedness: '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> > > >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
# Verdict Execution time Memory Grader output
1 Incorrect 1574 ms 4688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1657 ms 4668 KB Output isn't correct - 1.91%
2 Halted 0 ms 0 KB -