Submission #429946

# Submission time Handle Problem Language Result Execution time Memory
429946 2021-06-16T10:39:41 Z Jasiekstrz Vision Program (IOI19_vision) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>

#include "vision.h"

using namespace std;

const int X=200;

int h,w;

vector<int> primes;

bool composite[X+10];

int row[X+10]; // id of rows xor

int col[X+10]; // id of columns xor

vector<int> row_p[2];

vector<int> col_p[2];

int row_e[X+10];

int col_e[X+10];

int co(int x,int y)

{

	return (x-1)*w+y-1;

}

void construct_network(int H,int W,int K)

{

	vector<int> tmp;

	h=H;w=W;

	int it=h*w;

	int n=max(h,w);

	for(int i=2;i<=n;i++)

	{

		if(composite[i])

			continue;

		for(int j=i;j<=n;j*=i) primes.push_back(j);

		for(int j=2*i;j<=n;j+=i)

			composite[j]=true;

	}

 

	// rows

	for(int i=1;i<=h;i++)

	{

		row[i]=it++;

		tmp.clear();

		for(int j=1;j<=w;j++)

			tmp.push_back(co(i,j));

		add_xor(tmp);

	}

 

	// columns

	for(int j=1;j<=w;j++)

	{

		col[j]=it++;

		tmp.clear();

		for(int i=1;i<=h;i++)

			tmp.push_back(co(i,j));

		add_xor(tmp);

	}

 

	// rows divisors

	for(auto p:primes)

	{

		if(p>h)

			break;

		vector<int> modt(p);

		for(int i=1;i<=p;i++)

		{

			if(i+p>h)

				modt[i-1]=row[i];

			else

			{

				modt[i-1]=it++;

				tmp.clear();

				for(int j=i;j<=h;j+=p)

					tmp.push_back(row[j]);

				add_xor(tmp);

			}

		}

		row_p[0].push_back(it++);

		add_or(modt);

		row_p[1].push_back(it++);

		add_not(row_p[0].back());

		//cerr<<"row_p "<<p<<" {"<<row_p[1].back()<<","<<row_p[0].back()<<"}\n";

	}

 

	// columns divisors

	for(auto p:primes)

	{

		if(p>w)

			break;

		vector<int> modt(p);

		for(int i=1;i<=p;i++)

		{

			if(i+p>w)

				modt[i-1]=col[i];

			else

			{

				modt[i-1]=it++;

				tmp.clear();

				for(int j=i;j<=w;j+=p)

					tmp.push_back(col[j]);

				add_xor(tmp);

			}

		}

		col_p[0].push_back(it++);

		add_or(modt);

		col_p[1].push_back(it++);

		add_not(col_p[0].back());

		//cerr<<"col_p "<<p<<" {"<<col_p[1].back()<<","<<col_p[0].back()<<"}\n";

	}

 

	// rows equal

	if(h==1)

	{

		row_e[0]=it++;

		add_not(row[1]);

	}

	else

	{

		for(int i=0;i<h;i++)

		{

			row_e[i]=it++;

			tmp.clear();

			for(size_t j=0;j<row_p[1].size();j++)

				tmp.push_back(row_p[i%primes[j]==0][j]);

			add_and(tmp);

			//cerr<<"row_e "<<i<<" "<<row_e[i]<<"\n";

		}

	}

 

	// columns equal

	if(w==1)

	{

		col_e[0]=it++;

		add_not(col[1]);

	}

	else

	{

		for(int i=0;i<w;i++)

		{

			col_e[i]=it++;

			tmp.clear();

			for(size_t j=0;j<col_p[1].size();j++)

				tmp.push_back(col_p[i%primes[j]==0][j]);

			add_and(tmp);

			//cerr<<"col_e "<<i<<" "<<col_e[i]<<"\n";

		}

	}

 

	// answer

	vector<int> ans;

	for(int r=0;r<=min(K,h-1);r++)

	{

		int c=K-r;

		if(c>w-1)

			continue;

		ans.push_back(it++);

		tmp={row_e[r],col_e[c]};

		add_and(tmp);

	}

	add_or(ans);

	return;

}

Compilation message

vision.cpp:63:1: error: extended character   is not valid in an identifier
   63 |  
      | ^
vision.cpp:83:1: error: extended character   is not valid in an identifier
   83 |  
      | ^
vision.cpp:103:1: error: extended character   is not valid in an identifier
  103 |  
      | ^
vision.cpp:155:1: error: extended character   is not valid in an identifier
  155 |  
      | ^
vision.cpp:207:1: error: extended character   is not valid in an identifier
  207 |  
      | ^
vision.cpp:245:1: error: extended character   is not valid in an identifier
  245 |  
      | ^
vision.cpp:283:1: error: extended character   is not valid in an identifier
  283 |  
      | ^
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:63:1: error: '\U000000a0' was not declared in this scope
   63 |  
      | ^
vision.cpp:67:14: error: 'i' was not declared in this scope
   67 |  for(int i=1;i<=h;i++)
      |              ^
vision.cpp:83:3: error: expected ';' before 'for'
   83 |  
      |  ^
      |  ;
......
   87 |  for(int j=1;j<=w;j++)
      |  ~~~
vision.cpp:87:14: error: 'j' was not declared in this scope
   87 |  for(int j=1;j<=w;j++)
      |              ^
vision.cpp:103:3: error: expected ';' before 'for'
  103 |  
      |  ^
      |  ;
......
  107 |  for(auto p:primes)
      |  ~~~
vision.cpp:155:3: error: expected ';' before 'for'
  155 |  
      |  ^
      |  ;
......
  159 |  for(auto p:primes)
      |  ~~~
vision.cpp:207:3: error: expected ';' before 'if'
  207 |  
      |  ^
      |  ;
......
  211 |  if(h==1)
      |  ~~
vision.cpp:221:2: error: 'else' without a previous 'if'
  221 |  else
      |  ^~~~
vision.cpp:245:3: error: expected ';' before 'if'
  245 |  
      |  ^
      |  ;
......
  249 |  if(w==1)
      |  ~~
vision.cpp:259:2: error: 'else' without a previous 'if'
  259 |  else
      |  ^~~~
vision.cpp:283:3: error: expected ';' before 'vector'
  283 |  
      |  ^
      |  ;
......
  287 |  vector<int> ans;
      |  ~~~~~~
vision.cpp:299:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
  299 |   ans.push_back(it++);
      |   ^~~
      |   abs
vision.cpp:307:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
  307 |  add_or(ans);
      |         ^~~
      |         abs