Submission #1063672

# Submission time Handle Problem Language Result Execution time Memory
1063672 2024-08-17T22:57:31 Z aaaaaarroz Vision Program (IOI19_vision) C++17
Compilation error
0 ms 0 KB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
bool limites(int x, int y, int h, int w) {
	return x >= 0 && x < h && y >= 0 && y < w;
}
void construct_network(int H, int W, int K) {
	map<pair<int, int>, int> numero;
	int pos = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			numero[{i, j}] = pos;
			pos++;
		}
	}
	vector<int> dx, dy;
	for (int restar = 0; restar <= K; restar++) {
		int c_x = restar;
		int c_y = K - restar;
		dx.push_back(c_x);
		dy.push_back(c_y);
		if (c_x != 0) { 
			dx.push_back(-c_x);
			dy.push_back(c_y);
		}
	
		if (c_y != 0) {
			dx.push_back(c_x);
			dy.push_back(-c_y);
		}
	
		if (c_x != 0 && c_y != 0) {  
			dx.push_back(-c_x);
			dy.push_back(-c_y);
		}
	}
	map<pair<pair<int, int>, pair<int, int>>, bool> marked;
	int pos=1;
	vector<int>xd;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			for (int itr = 0; itr < dx.size(); itr++) {
				int x = i + dx[itr];
				int y = j + dy[itr];
				vector<int>vecinos;
				if (limites(x, y, H, W)) {
					if (!marked[{{i, j}, {x, y}}] && !marked[{{x, y}, {i, j}}]) {
						vecinos.push_back({numero[{x,y}]});
						marked[{{i, j}, {x, y}}] = true;
					}
				}
				if(!vecinos.empty()){
					xd.push_back(add_and({numero[{i,j}],add_or(vecinos)}));
				}
			}
		}
	}
	add_or(xd);
	return;
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:38:6: error: redeclaration of 'int pos'
   38 |  int pos=1;
      |      ^~~
vision.cpp:9:6: note: 'int pos' previously declared here
    9 |  int pos = 0;
      |      ^~~
vision.cpp:42:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |    for (int itr = 0; itr < dx.size(); itr++) {
      |                      ~~~~^~~~~~~~~~~