Submission #894341

# Submission time Handle Problem Language Result Execution time Memory
894341 2023-12-28T06:56:19 Z Faisal_Saqib Vision Program (IOI19_vision) C++17
Compilation error
0 ms 0 KB
#include <vector>
#include <string>
#include <map>
using namespace std;

int add_and(std::vector<int> Ns);

int add_or(std::vector<int> Ns);

int add_xor(std::vector<int> Ns);

int add_not(int N);
int h,w,k;
int which_diagonal1[40001];
int dia=0;
int dia1=0;
int which_diagonal2[40001];
int index_of_diagonal1[401];
int index_of_diagonal2[401];
int f(int i,int j)
{
	return (i*w)+j;
}
int check_distance_is_atmost_x(int x)
{
	// check subarray of length x+1
	vector<int> dp;
	for(int di=0;(di+x)<dia;di++)
	{
		vector<int> cur;
		for(int j=0;j<=x;j++)
			cur.push_back(index_of_diagonal1[di+j]);
		dp.push_back(add_xor({add_xor(cur),add_or(cur)}));
	}
	// Ask xor and or
	// if xor==0 and or==1 then distance is atmost 
	// if(dp.size()==0)
	// {
	// 	cout<<"size of dp is "<<0<<endl;
	// 	exit(-100);
	// }
	if(dp.size()==1)
		return dp[0];
	return add_or(dp);
}
int check_distance_is_atmost_x1(int x)
{
	// check subarray of length x+1
	vector<int> dp;
	for(int di=0;(di+x)<dia1;di++)
	{
		vector<int> cur;
		for(int j=0;j<=x;j++)
			cur.push_back(index_of_diagonal2[di+j]);
		dp.push_back(add_xor({add_xor(cur),add_or(cur)}));
	}
	// Ask xor and or
	// if xor==0 and or==1 then distance is atmost 
	if(dp.size()==1)
		return dp[0];
	return add_or(dp);
}
void construct_network(int H, int W, int K)
{
	h=H;
	w=W;
	k=K;
	for(int j=0;j<1;j++)
	{
		for(int i=h-1;i>=0;i--)
		{
			vector<int> element;
			int ci=i;
			int cj=j;
			while(ci<h and cj<w)
			{
				element.push_back(f(ci,cj));
				which_diagonal1[f(ci,cj)]=dia;
				ci++;
				cj++;
			}
			index_of_diagonal1[dia]=add_or(element);
			dia++;
		}
	}
	for(int i=0;i<1;i++)
	{
		for(int j=1;j<w;j++)
		{
			int ci=i;
			int cj=j;
			vector<int> element;
			while(ci<h and cj<w)
			{
				element.push_back(f(ci,cj));
				which_diagonal1[f(ci,cj)]=dia;
				ci++;
				cj++;
			}
			index_of_diagonal1[dia]=add_or(element);
			dia++;
		}
	}
	int fff=check_distance_is_atmost_x(k);
	int fss=check_distance_is_atmost_x(k-1);
	int check_for_d1=add_and(add_and({fff,add_not(fss)}));
	dia1=0;
	for(int i=0;i<1;i++)
	{
		for(int j=0;j<w;j++)
		{
			int ci=i;
			int cj=j;
			vector<int> element;
			while(ci<h and cj>=0)
			{
				element.push_back(f(ci,cj));
				ci++;
				cj--;
			}		
			index_of_diagonal2[dia1]=add_or(element);
			dia1++;	
		}
	}
	for(int j=w-1;j<w;j++)
	{
		for(int i=1;i<h;i++)
		{
			int ci=i;
			int cj=j;
			vector<int> element;
			while(ci<h and cj>=0)
			{
				element.push_back(f(ci,cj));
				ci++;
				cj--;
			}		
			index_of_diagonal2[dia1]=add_or(element);
			dia1++;
		}
	}
	int fff1=check_distance_is_atmost_x1(k);
	int fss1=check_distance_is_atmost_x1(k-1);
	int check_for_d2=add_and(add_and({fff1,add_not(fss1)}));
	add_or(check_for_d1,check_for_d2);
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:106:34: error: could not convert 'add_and(std::vector<int>(std::initializer_list<int>{((const int*)(& const int [2]{fff, add_not(fss)})), 2}, std::allocator<int>()))' from 'int' to 'std::vector<int>'
  106 |  int check_for_d1=add_and(add_and({fff,add_not(fss)}));
      |                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~
      |                                  |
      |                                  int
vision.cpp:144:34: error: could not convert 'add_and(std::vector<int>(std::initializer_list<int>{((const int*)(& const int [2]{fff1, add_not(fss1)})), 2}, std::allocator<int>()))' from 'int' to 'std::vector<int>'
  144 |  int check_for_d2=add_and(add_and({fff1,add_not(fss1)}));
      |                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
      |                                  |
      |                                  int
vision.cpp:145:9: error: could not convert 'check_for_d1' from 'int' to 'std::vector<int>'
  145 |  add_or(check_for_d1,check_for_d2);
      |         ^~~~~~~~~~~~
      |         |
      |         int