Submission #602788

# Submission time Handle Problem Language Result Execution time Memory
602788 2022-07-23T11:15:25 Z MeGustaElArroz23 Vision Program (IOI19_vision) C++14
0 / 100
18 ms 2256 KB
#include "vision.h"

#include<bits/stdc++.h>
using namespace std;

#define vi vector<int>
#define vvi vector<vi>
#define pb push_back

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

	//W width H height

	//diagonales 	|_

		//distancia K

	vi diagonales;
	for (int i=0;i<H+W-1;i++){
		vi acdiagonal(0);
		for (int h=0;h<H;h++){
			if (i-h<W && i-h>=0) acdiagonal.pb((i-h)+W*h);
		}
		diagonales.pb(add_or(acdiagonal));
	}

	vi comparaciones;
	for (int i=0;i+K<diagonales.size();i++) 
		comparaciones.pb(add_and(vi{diagonales[i],diagonales[i+K]}));
	
	int distancia_K_1=add_or(comparaciones);

		//distancia <=K

	diagonales=vi(0);
	for (int i=0;i<H+W-1;i++){
		vi acdiagonal(0);
		for (int h=0;h<H;h++){
			if (i-h<W && i-h>=0) acdiagonal.pb((i-h)+W*h);
		}
		diagonales.pb(add_or(acdiagonal));
	}

	comparaciones=vi(0);
	for (int i=0;i+K<diagonales.size();i++){
		vi porcomparar(0);
		for (int j=i;j<=i+K;j++) porcomparar.pb(diagonales[j]);
		comparaciones.pb(add_or(porcomparar));
	}

	int res=comparaciones[0];
	for (int i=1;i<comparaciones.size();i++)
		res=add_xor(vi{res,
			add_and(vi{add_not(comparaciones[i-1]),comparaciones[i]})
		});

	int distancia_less_K_1=res;

	//diagonales 	_|

		//distancia K

	diagonales=vi(0);
	for (int i=0;i<H+W-1;i++){
		vi acdiagonal(0);
		for (int h=0;h<H;h++){
			if (i-h<W && i-h>=0) acdiagonal.pb((W-(i-h))+W*h);
		}
		diagonales.pb(add_or(acdiagonal));
	}

	comparaciones=vi(0);
	for (int i=0;i+K<diagonales.size();i++) 
		comparaciones.pb(add_and(vi{diagonales[i],diagonales[i+K]}));
	
	int distancia_K_2=add_or(comparaciones);

		//distancia <=K

	diagonales=vi(0);
	for (int i=0;i<H+W-1;i++){
		vi acdiagonal(0);
		for (int h=0;h<H;h++){
			if (i-h<W && i-h>=0) acdiagonal.pb((W-(i-h))+W*h);
		}
		diagonales.pb(add_or(acdiagonal));
	}

	comparaciones=vi(0);
	for (int i=0;i+K<diagonales.size();i++){
		vi porcomparar(0);
		for (int j=i;j<=i+K;j++) porcomparar.pb(diagonales[j]);
		comparaciones.pb(add_or(porcomparar));
	}

	res=comparaciones[0];
	for (int i=1;i<comparaciones.size();i++)
		res=add_xor(vi{res,
			add_and(vi{add_not(comparaciones[i-1]),comparaciones[i]})
		});

	int distancia_less_K_2=res;

	//FINAL

	add_or(vi{
		add_and(vi{distancia_K_1,distancia_less_K_2}),
		add_and(vi{distancia_K_2,distancia_less_K_1})
	});

	
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:28:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |  for (int i=0;i+K<diagonales.size();i++)
      |               ~~~^~~~~~~~~~~~~~~~~~
vision.cpp:45:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |  for (int i=0;i+K<diagonales.size();i++){
      |               ~~~^~~~~~~~~~~~~~~~~~
vision.cpp:52:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |  for (int i=1;i<comparaciones.size();i++)
      |               ~^~~~~~~~~~~~~~~~~~~~~
vision.cpp:73:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |  for (int i=0;i+K<diagonales.size();i++)
      |               ~~~^~~~~~~~~~~~~~~~~~
vision.cpp:90:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |  for (int i=0;i+K<diagonales.size();i++){
      |               ~~~^~~~~~~~~~~~~~~~~~
vision.cpp:97:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   97 |  for (int i=1;i<comparaciones.size();i++)
      |               ~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB on inputs (0, 0), (0, 2), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB on inputs (0, 0), (0, 2), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB on inputs (0, 0), (0, 2), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB on inputs (0, 0), (0, 2), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 468 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 232 KB on inputs (0, 0), (1, 1), expected 0, but computed 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 2256 KB Output is correct
2 Incorrect 1 ms 212 KB on inputs (0, 1), (1, 0), expected 0, but computed 1
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB on inputs (0, 0), (0, 2), expected 0, but computed 1
2 Halted 0 ms 0 KB -