Submission #144874

#TimeUsernameProblemLanguageResultExecution timeMemory
144874joseacazVision Program (IOI19_vision)C++17
12 / 100
11 ms1144 KiB
#include "vision.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void construct_network ( int H, int W, int K )
{
	vi rows, cols, ind, auxrow, auxcol, fin;
	for ( int i = 0; i < H; i++ )
	{
		ind.clear();
		for ( int j = 0; j < W; j++ )
			ind.push_back ( i * W + j );
		
		rows.push_back ( add_or ( ind ) );
	}

	for ( int j = 0; j < W; j++ )
	{
		ind.clear();
		for ( int i = 0; i < H; i++ )
			ind.push_back ( i * W + j );
		
		cols.push_back ( add_or ( ind ) );
	}
	
	fin.clear();
	auxrow.clear();
	for ( int x = 0; x + K < H; x++ )
	{
		ind.clear();
		ind.push_back ( rows[x] );
		ind.push_back ( rows[x + K] );
		auxrow.push_back ( add_and ( ind ) );
	}
	if ( !auxrow.empty() )
		fin.push_back ( add_or ( auxrow ) );

	auxcol.clear();
	for ( int x = 0; x + K < W; x++ )
	{
		ind.clear();
		ind.push_back ( cols[x] );
		ind.push_back ( cols[x + K] );
		auxcol.push_back ( add_and ( ind ) );
	}
	if ( !auxcol.empty() )
		fin.push_back ( add_or ( auxcol ) );

	for ( int i = 1; i < K; i++ )
	{
		if ( i < H && K - i < W )
		{
			auxrow.clear(), auxcol.clear();

			for ( int x = 0; x + i < H; x++ )
			{
				ind.clear();
				ind.push_back ( rows[x] );
				ind.push_back ( rows[x + i] );
				auxrow.push_back ( add_and ( ind ) );
			}

			for ( int x = 0; x + K - i < W; x++ )
			{
				ind.clear();
				ind.push_back ( cols[x] );
				ind.push_back ( cols[x + K - i] );
				auxcol.push_back ( add_and ( ind ) );
			}
			
			ind.clear();
			ind.push_back ( add_or ( auxrow ) );
			ind.push_back ( add_or ( auxcol ) );

			fin.push_back ( add_and ( ind ) );
		}
	}
	
	add_or ( fin );
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...