Submission #913832

# Submission time Handle Problem Language Result Execution time Memory
913832 2024-01-20T10:20:53 Z Muhammad_Aneeq Last supper (IOI12_supper) C++17
Compilation error
0 ms 0 KB
#include "advisor.h"
#include <cmath>
#include <map>
#include <set>
#include <iostream>
void ComputeAdvice(int *C, int N, int K, int M)
{
	for (int i=0;i<N;i++)
	{
		for (int j=0;j<=log2(N);j++)
		{
			if ((1<<j)&C[i])
				WriteAdvice(1);
			else
				WriteAdvice(0);
		}
	}
}
#include "assistant.h"
#include <cmath>
#include <map>
#include <set>
#include <iostream>
void Assist(unsigned char *A, int N, int K, int R)
{
	int re[N]={};
	int z=log2(N);
	map<int,int>d;
	set<int>res[N]={};
	for (int i=0;i<N;i++)
	{
		for (int j=0;j<=z;j++)
			re[i]+=(A[i*(z+1)+j]<<j);
		res[re[i]].insert(i);
		d[re[i]]++;
	}
	set<int>ind;
	for (int i=0;i<K;i++)
		ind.insert(i);
	for (int i=0;i<N;i++)
	{
		int z=GetRequest();
		d[z]--;
		res[z].erase(i); 
		if (ind.find(z)!=ind.end())
			continue;	
		int x=0;
		int f=-1;
		for (auto i:ind)
		{
			if (d[i]==0)
			{
				x=i;
				f=-1;
				break;
			}
			else
			{
				if (res[i].size()&&*begin(res[i])>f)
				{
					f=*begin(res[i]);
					x=i;
				}
			}
		}
		PutBack(x);
		ind.insert(z);
		ind.erase(x);
		res[i].erase(f);
	}
}

Compilation message

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:10:2: error: 'map' was not declared in this scope
   10 |  map<int,int>d;
      |  ^~~
assistant.cpp:10:2: note: suggested alternatives:
In file included from /usr/include/c++/10/map:61,
                 from assistant.cpp:3:
/usr/include/c++/10/bits/stl_map.h:100:11: note:   'std::map'
  100 |     class map
      |           ^~~
In file included from assistant.cpp:3:
/usr/include/c++/10/map:78:13: note:   'std::pmr::map'
   78 |       using map
      |             ^~~
assistant.cpp:10:6: error: expected primary-expression before 'int'
   10 |  map<int,int>d;
      |      ^~~
assistant.cpp:11:2: error: 'set' was not declared in this scope
   11 |  set<int>res[N]={};
      |  ^~~
assistant.cpp:11:2: note: suggested alternatives:
In file included from /usr/include/c++/10/set:61,
                 from assistant.cpp:4:
/usr/include/c++/10/bits/stl_set.h:94:11: note:   'std::set'
   94 |     class set
      |           ^~~
In file included from assistant.cpp:4:
/usr/include/c++/10/set:78:13: note:   'std::pmr::set'
   78 |       using set = std::set<_Key, _Cmp, polymorphic_allocator<_Key>>;
      |             ^~~
assistant.cpp:11:6: error: expected primary-expression before 'int'
   11 |  set<int>res[N]={};
      |      ^~~
assistant.cpp:16:3: error: 'res' was not declared in this scope; did you mean 're'?
   16 |   res[re[i]].insert(i);
      |   ^~~
      |   re
assistant.cpp:17:3: error: 'd' was not declared in this scope
   17 |   d[re[i]]++;
      |   ^
assistant.cpp:19:6: error: expected primary-expression before 'int'
   19 |  set<int>ind;
      |      ^~~
assistant.cpp:21:3: error: 'ind' was not declared in this scope; did you mean 'int'?
   21 |   ind.insert(i);
      |   ^~~
      |   int
assistant.cpp:25:3: error: 'd' was not declared in this scope
   25 |   d[z]--;
      |   ^
assistant.cpp:26:3: error: 'res' was not declared in this scope; did you mean 're'?
   26 |   res[z].erase(i);
      |   ^~~
      |   re
assistant.cpp:27:7: error: 'ind' was not declared in this scope; did you mean 'int'?
   27 |   if (ind.find(z)!=ind.end())
      |       ^~~
      |       int
assistant.cpp:31:15: error: 'ind' was not declared in this scope; did you mean 'int'?
   31 |   for (auto i:ind)
      |               ^~~
      |               int
assistant.cpp:41:25: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   41 |     if (res[i].size()&&*begin(res[i])>f)
      |                         ^~~~~
      |                         std::begin
In file included from /usr/include/c++/10/array:41,
                 from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/bits/stl_map.h:63,
                 from /usr/include/c++/10/map:61,
                 from assistant.cpp:3:
/usr/include/c++/10/bits/range_access.h:108:37: note: 'std::begin' declared here
  108 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&);
      |                                     ^~~~~
assistant.cpp:49:3: error: 'ind' was not declared in this scope; did you mean 'int'?
   49 |   ind.insert(z);
      |   ^~~
      |   int