[Noti-aed] Holsman Juan Manuel TPL: cr7 y kfill
Juan Holsman
holsman97 en gmail.com
Mar Nov 22 17:12:14 -03 2022
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://venus.santafe-conicet.gov.ar/pipermail/noti-aed/attachments/20221122/92ecaffc/attachment.html>
------------ próxima parte ------------
#define USECHRONO
#undef HAVE_MPI
#include "eval.hpp"
#include <cassert>
#include <climits>
#include <cstdlib>
#include <stack>
#include <unistd.h>
#include <set>
#include <list>
using namespace aed;
using namespace std;
//---:---<*>---:---<*>- COMIENZA CODIGO FUNCION --:---<*>---:---<*>---:---<*>
// COMPLETAR DNI y NOMBRE AQUI:
// Nombre: Bob Esponja
int DNI=23456789;
//---:---<*>---:---<*>---:---<*>---:---<*>---:---<*>
void subk(set<int> &S, set<int> C, set<int>::iterator itS, list<set<int>> &LK)
{
if (itS == S.end()) return;
// LK.insert(LK.begin(),C);
//almacena set actual
set<int> D = C;
//agrego *itS a C
C.insert(C.end(), *itS);
itS++;
// se agrega C a la lista si C.size = k
// if (C.size() == k)
LK.insert(LK.end(),C);
//bifurcación:
//Rama 1: agregando
subk(S,C,itS,LK);
//Rama 2: no agregando
subk(S,D,itS,LK);
}
//wrapper
list<set<int>> subk(set<int> &S)
{
set<int> C;
C.clear();
list<set<int>> LK;
set<int>::iterator itS = S.begin();
subk(S,C,itS,LK);
return LK;
}
bool prom_subc(set<int> &S) {
// COMPLETAR
int sum=0;
set<int>::iterator it=S.begin();
while(it!=S.end()){
sum+=*it;
it++;
}
int t=S.size();
int prom=sum/t;
if(prom==0 || prom==-0) return true;
list<set<int>> LK= subk(S);
list<set<int>>::iterator itLK=LK.begin();
while(itLK!=LK.end()){
set<int>saux= *itLK;
set<int>::iterator itS=saux.begin();
int sum=0;
while(itS!=saux.end()){
sum+=*itS;
itS++;
}
if(sum==prom) return true;
itLK++;
}
return false;
}
int main() {
Eval ev;
int vrbs = 0;
ev.eval<1>(prom_subc,vrbs);
return 0;
}
------------ próxima parte ------------
#define USECHRONO
#undef HAVE_MPI
#include "eval.hpp"
#include <cassert>
#include <climits>
#include <cstdlib>
#include <stack>
#include <unistd.h>
#include <list>
#include <tree.hpp>
using namespace aed;
using namespace std;
//---:---<*>---:---<*>- COMIENZA CODIGO FUNCION --:---<*>---:---<*>---:---<*>
// COMPLETAR DNI y NOMBRE AQUI:
// Nombre: Holsman Juan Manuel
int DNI=40554377;
//---:---<*>---:---<*>---:---<*>---:---<*>---:---<*>
//COMPLETAR!
list<int> cr7(tree<int> &T, tree<int>::iterator it){
if(*it==7){
return {*it};
}
tree<int>::iterator c = it.lchild();
while(c!=T.end()){
list<int> Laux = cr7(T,c);
int tam=Laux.size();
if(tam){
Laux.push_front(*it);
return Laux;
}
c++;
}
list<int> aux;
return aux;
}
list<int> cr7(tree<int> &T){
return cr7(T,T.begin());
}
int main() {
Eval ev;
int vrbs = 0;
ev.eval<1>(cr7,vrbs);
return 0;
}
Más información sobre la lista de distribución Noti-AED