Submission #429862

# Submission time Handle Problem Language Result Execution time Memory
429862 2021-06-16T10:06:01 Z Jasiekstrz Vision Program (IOI19_vision) C++17
0 / 100
21 ms 1752 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;
		primes.push_back(i);
		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
	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
	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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Incorrect 2 ms 460 KB on inputs (0, 0), (100, 28), expected 0, but computed 1
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1752 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 2 ms 460 KB Output is correct
4 Correct 4 ms 588 KB Output is correct
5 Incorrect 1 ms 460 KB WA in grader: Instruction with no inputs
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB WA in grader: Instruction with no inputs
2 Halted 0 ms 0 KB -