Submission #723391

# Submission time Handle Problem Language Result Execution time Memory
723391 2023-04-13T16:57:29 Z mimmocostes Measures (CEOI22_measures) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

int N, M;
long long D;

string half (long long N) {
	if (N%2 == 0) {
		return to_string(N/2);
	} else {
		return to_string(N/2)+".5";
	}
}

struct Personne {
	long long position;
	bool initiale;
	int ordre;

	bool operator< (Personne b) {
		return position < b.position;
	};
};
vector<Personne> personnes;
vector<int> a_ajouter;

struct Noeud;
struct Noeud {
	long long mini = INT_MAX,
			  maxi = 0;
	long long calc = INT_MAX;

	long long shift = 0;
}
struct Arbre {
	vector<Noeud> noeuds;

	void init (int N) {
		int nbNoeuds = 1<<ceil(log2(N));
		noeuds.resize(nbNoeuds*2-1);

		int nbGauche = 0;
		for (int i=0; i<N; i++) {
			if (personnes[nbNoeuds-1+i].initiale) {
				noeuds[i].mini = personnes[nbNoeuds-1+i].
				noeuds[i].maxi = personnes[nbNoeuds-1+i].
				noeuds[i].calc = nbGauche;
				nbGauche++;
			}
		}

		int k=2;
		while (k<=N) {
			for (int i=0; i<N; i+=k) {
				int g = get_filsgauche();
			}

			k *= 2;
		}
	}

	Noeud fusion (Noeud gauche, Noeud droite, Noeud parent) {
		parent.mini = min(gauche.mini, droite.mini);
		parent.maxi = max(gauche.maxi, droite.maxi);
		parent.calc = max();

		return parent;
	}

	int get_depth (int N) {
		return floor(log2(N+1));
	}

	int get_filsgauche (int N) {
		int depth = get_depth(N);
		int offset = 1<<depth -1;
		int pos = N - offset;
		return 1<<(depth+1) -1 +offset/2;
	}
	int get_parent (int N) {
		if (N==0) return 0;
		int depth = get_depth(N);
		int offset = 1<<depth -1;
		int pos = N - offset;
		return 1<<(depth-1) -1 +offset*2;
	}
};

int main () {
	cin >> N >> M >> D;


	personnes.resize(N+M);

	for (int i=0; i<N; i++) {
		cin >> personnes[i].position;
		personnes[i].initiale = true;
	}
	for (int i=0; i<M; i++) {
		cin >> personnes[i].position;
		personnes[i].initiale = false;
		personnes[i].ordre = i;
	}

	sort(personnes.begin(), personnes.end());

	a_ajouter.resize(M);
	for (int i=0; i<N+M; i++) {
		if (!personnes[i].initiale) {
			a_ajouter[personnes[i].ordre] = i;
		}
	}

	// for (int k=0; k<M; k++) {
	// 	initial.push_back(added[k]);

	// 	sort(initial.begin(), initial.end());

	// 	long long M = 0;
	// 	for (long long i=0; i<N+k+1; i++) {
	// 		for (long long j=i+1; j<N+k+1; j++) {
				
	// 			M = max(M, D*(j-i) - (initial[j]-initial[i]));
	// 		}
	// 	}
	// 	cout << half(M) << endl;
	// }
}

Compilation message

Main.cpp:35:2: error: expected ';' after struct definition
   35 | }
      |  ^
      |  ;
Main.cpp: In member function 'void Arbre::init(int)':
Main.cpp:40:19: error: invalid operands of types 'int' and 'double' to binary 'operator<<'
   40 |   int nbNoeuds = 1<<ceil(log2(N));
      |                  ~^~~~~~~~~~~~~~~
      |                  |      |
      |                  int    double
Main.cpp:47:5: error: '__gnu_cxx::__alloc_traits<std::allocator<Personne>, Personne>::value_type' {aka 'struct Personne'} has no member named 'noeuds'
   47 |     noeuds[i].maxi = personnes[nbNoeuds-1+i].
      |     ^~~~~~
Main.cpp:48:5: error: '__gnu_cxx::__alloc_traits<std::allocator<Personne>, Personne>::value_type' {aka 'struct Personne'} has no member named 'noeuds'
   48 |     noeuds[i].calc = nbGauche;
      |     ^~~~~~
Main.cpp:56:28: error: no matching function for call to 'Arbre::get_filsgauche()'
   56 |     int g = get_filsgauche();
      |                            ^
Main.cpp:75:6: note: candidate: 'int Arbre::get_filsgauche(int)'
   75 |  int get_filsgauche (int N) {
      |      ^~~~~~~~~~~~~~
Main.cpp:75:6: note:   candidate expects 1 argument, 0 provided
Main.cpp:56:9: warning: unused variable 'g' [-Wunused-variable]
   56 |     int g = get_filsgauche();
      |         ^
Main.cpp: In member function 'Noeud Arbre::fusion(Noeud, Noeud, Noeud)':
Main.cpp:66:21: error: no matching function for call to 'max()'
   66 |   parent.calc = max();
      |                     ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
Main.cpp:66:21: note:   candidate expects 2 arguments, 0 provided
   66 |   parent.calc = max();
      |                     ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
Main.cpp:66:21: note:   candidate expects 3 arguments, 0 provided
   66 |   parent.calc = max();
      |                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
Main.cpp:66:21: note:   candidate expects 1 argument, 0 provided
   66 |   parent.calc = max();
      |                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
Main.cpp:66:21: note:   candidate expects 2 arguments, 0 provided
   66 |   parent.calc = max();
      |                     ^
Main.cpp: In member function 'int Arbre::get_filsgauche(int)':
Main.cpp:77:25: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   77 |   int offset = 1<<depth -1;
      |                   ~~~~~~^~
Main.cpp:79:26: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   79 |   return 1<<(depth+1) -1 +offset/2;
      |             ~~~~~~~~~~~~~^~~~~~~~~
Main.cpp:78:7: warning: unused variable 'pos' [-Wunused-variable]
   78 |   int pos = N - offset;
      |       ^~~
Main.cpp: In member function 'int Arbre::get_parent(int)':
Main.cpp:84:25: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   84 |   int offset = 1<<depth -1;
      |                   ~~~~~~^~
Main.cpp:86:26: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   86 |   return 1<<(depth-1) -1 +offset*2;
      |             ~~~~~~~~~~~~~^~~~~~~~~
Main.cpp:85:7: warning: unused variable 'pos' [-Wunused-variable]
   85 |   int pos = N - offset;
      |       ^~~