Submission #811068

# Submission time Handle Problem Language Result Execution time Memory
811068 2023-08-06T22:59:52 Z oscar1f Comparing Plants (IOI20_plants) C++17
Compilation error
0 ms 0 KB
#include "tickets.h"
#include <bits/stdc++.h>

using namespace std;
using ll=long long;
using vv=vector<vector<ll>>;

const int MAX_SORTE=1505;
ll nbSorte,nbDeChaque,nbTour;
vv val,pris;
vector<ll> listeGrand[MAX_SORTE],listePetit[MAX_SORTE];
set<ll> restants[MAX_SORTE];

ll calcRep() {
	ll sommeRep=0;
	vector<tuple<ll,ll,ll>> listePris;
	vector<vector<int>> rep;
	vector<ll> nbPris,meilleur;
	for (ll i=0;i<nbSorte;i++) {
		rep.push_back({});
		for (ll j=0;j<nbDeChaque;j++) {
			if (pris[i][j]==1) {
				listePris.push_back(make_tuple(val[i][j],i,j));
				rep[i].push_back(0);
			}
			else {
				rep[i].push_back(-1);
			}
		}
		for (ll j=0;j<nbTour;j++) {
			restants[i].insert(j);
		}
	}
	sort(listePris.begin(),listePris.end());
	for (ll i=0;i<(ll)listePris.size();i++) {
		if (i<(ll)listePris.size()/2) {
			sommeRep-=get<0>(listePris[i]);
			listePetit[get<1>(listePris[i])].push_back(get<2>(listePris[i]));
		}
		else {
			sommeRep+=get<0>(listePris[i]);
			listeGrand[get<1>(listePris[i])].push_back(get<2>(listePris[i]));
		}
	} 
	for (ll i=0;i<nbTour;i++) {
		meilleur.push_back(i);
		nbPris.push_back(0);
	}
	for (ll i=0;i<nbSorte;i++) {
		/*cout<<i<<" : ";
		for (auto l:listePetit[i]) {
			cout<<l<<" ";
		}
		cout<<"\t";
		for (auto l:listeGrand[i]) {
			cout<<l<<" ";
		}
		cout<<endl;*/
		sort(meilleur.begin(),meilleur.end(),[&] (int a,int b){
			return nbPris[a]<nbPris[b];
		});
		/*for (int i:meilleur) {
			cout<<i<<" ";
		}
		cout<<endl;*/
		for (ll j=0;j<(ll)listePetit[i].size();j++) {
			rep[i][listePetit[i][j]]=meilleur[j];
			nbPris[meilleur[j]]++;
			restants[i].erase(meilleur[j]);
		}
		for (ll j:listeGrand[i]) {
			auto it=restants[i].begin();
			rep[i][j]=(*it);
			restants[i].erase(it);
		}
	}
	allocate_tickets(rep);
	return sommeRep;
}

ll find_maximum(int k,vector<vector<int>> x) {
	for (auto i:x) {
		val.push_back({});
		for (auto j:i) {
			val.back().push_back((ll)j);
		}
	}
	nbTour=k;
	nbSorte=val.size();
	nbDeChaque=val[0].size();
	for (ll i=0;i<nbSorte;i++) {
		pris.push_back({});
		for (ll j=0;j<nbDeChaque;j++) {
			pris.back().push_back(0);
		}
	}
	if (nbTour==nbDeChaque) {
		for (ll i=0;i<nbSorte;i++) {
			for (ll j=0;j<nbDeChaque;j++) {
				pris[i][j]=1;
			}
		}
	}
	return calcRep();
}

Compilation message

plants.cpp:1:10: fatal error: tickets.h: No such file or directory
    1 | #include "tickets.h"
      |          ^~~~~~~~~~~
compilation terminated.