Submission #682739

# Submission time Handle Problem Language Result Execution time Memory
682739 2023-01-16T21:18:49 Z APROHACK Vision Program (IOI19_vision) C++14
44 / 100
9 ms 1452 KB
#include "vision.h"
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
int h, w, k;
bool valid(int x, int y){
	return (x < h && y < w && x >= 0 &&  y >= 0);
}
int coordenadasAPosicion (int x, int y){
	return x*w + y;
}


void construct_network(int H, int W, int K) {
	h = H, w = W, k = K;
	int cuenta = 0;
	vector<int>toOr;
	if(k != 1 || h*w <= 1000){
		for(int i = 0 ; i < H ; i ++){
			for(int j = 0 ; j < W ; j ++){
				if(valid(i, j)){
					vector<int>toXor;
					//cout << "Esto fue para " << i << " " << j << endl;
					for(int abajo = k ; abajo > -k ; abajo--){
						
						if(valid(i+abajo, j+k-abs(abajo))){
							//cout << "valid = " << i+abajo << ", " << j+k-abs(abajo)<<endl;
							toXor.pb(coordenadasAPosicion(i+abajo, j+k-abs(abajo)));
							//add_and({coordenadasAPosicion(i, j), coordenadasAPosicion(i+abajo, j+k-abs(abajo))});
							//cuenta ++;
						}
					}
					
					if(toXor.empty())continue;
					toXor.pb(coordenadasAPosicion(i, j));
					add_xor(toXor);
					add_not({H*W+cuenta});
					//cout << "analising " << H*W+cuenta << endl;
					cuenta+=2;
					add_and({H*W+cuenta-1, coordenadasAPosicion(i, j)});
					//cout << "and to position" << H*W+cuenta-1 << endl;
					cuenta++;
					toOr.pb({H*W+cuenta-1});

					

				}
			}
		}
		add_or(toOr);
		return ;
	}






	//firstXOR
	vector<int>resultadosXORES[2];
	for(int j = 0 ; j < W; j ++){
		vector<int>toXOR;
		for(int i = 0 ; i < H ; i ++){
			toXOR.pb(coordenadasAPosicion(i, j));
		}
		add_xor(toXOR);
		resultadosXORES[0].pb(H*W+cuenta);
		cuenta ++;
	}


	for(int i = 0 ; i < H ; i ++){
		vector<int>toXOR;
		for(int j = 0 ; j < W ; j ++){
			toXOR.pb(coordenadasAPosicion(i, j));
		}
		add_xor(toXOR);
		resultadosXORES[1].pb(H*W+cuenta);
		cuenta++;
	}
	vector<int>resultadosANDS[2];
	for(int i = 0 ; i+1 < resultadosXORES[0].size() ; i++){
		add_and({resultadosXORES[0][i], resultadosXORES[0][i+1]});
		resultadosANDS[0].pb(H*W+cuenta);
		cuenta ++;
	}
	for(int i = 0 ; i+1 < resultadosXORES[1].size() ; i++){
		add_and({resultadosXORES[1][i], resultadosXORES[1][i+1]});
		resultadosANDS[1].pb(H*W+cuenta);
		cuenta ++;
	}
	vector<int>resultadosORS;
	vector<int>toAdd;
	for(int i = 0 ; i < resultadosANDS[0].size() ; i++){
		toAdd.pb(resultadosANDS[0][i]);
	}
	add_or(toAdd);
	resultadosORS.pb(H*W+cuenta);
	cuenta ++;
	toAdd.clear();

	for(int i = 0 ; i < resultadosANDS[1].size() ; i++){
		toAdd.pb(resultadosANDS[1][i]);
	}
	add_or(toAdd);
	resultadosORS.pb(H*W+cuenta);
	cuenta ++;
	vector<int>finalXOR[2];
	for(int i = 0 ; i < resultadosXORES[0].size() ; i++){
		finalXOR[0].pb(resultadosXORES[0][i]);
	}
	for(int i = 0 ; i < resultadosXORES[1].size() ; i++){
		finalXOR[1].pb(resultadosXORES[1][i]);
	}

	int ResultadoFinalXOR[2];
	add_xor(finalXOR[0]);
	ResultadoFinalXOR[0] = H*W+cuenta;
	cuenta ++;
	add_xor(finalXOR[1]);
	ResultadoFinalXOR[1] = H*W+cuenta;
	cuenta ++;

	add_and({resultadosORS[0], ResultadoFinalXOR[1]});
	int respuesta[2];
	respuesta[0] = H*W+cuenta;
	cuenta ++;
	add_and({resultadosORS[1], ResultadoFinalXOR[0]});
	respuesta[1] = H*W+cuenta;
	cuenta ++;
	add_or({respuesta[0], respuesta[1]});

}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:85:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |  for(int i = 0 ; i+1 < resultadosXORES[0].size() ; i++){
      |                  ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
vision.cpp:90:22: 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+1 < resultadosXORES[1].size() ; i++){
      |                  ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
vision.cpp:97:20: 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 = 0 ; i < resultadosANDS[0].size() ; i++){
      |                  ~~^~~~~~~~~~~~~~~~~~~~~~~~~~
vision.cpp:105:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  105 |  for(int i = 0 ; i < resultadosANDS[1].size() ; i++){
      |                  ~~^~~~~~~~~~~~~~~~~~~~~~~~~~
vision.cpp:112:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  112 |  for(int i = 0 ; i < resultadosXORES[0].size() ; i++){
      |                  ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
vision.cpp:115:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  115 |  for(int i = 0 ; i < resultadosXORES[1].size() ; i++){
      |                  ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 272 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 300 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 272 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 300 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 1 ms 304 KB Output is correct
22 Correct 0 ms 300 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 300 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 272 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 300 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 1 ms 304 KB Output is correct
22 Correct 0 ms 300 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 300 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 4 ms 596 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 3 ms 596 KB Output is correct
35 Correct 2 ms 596 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 272 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 300 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 1 ms 304 KB Output is correct
22 Correct 0 ms 300 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 300 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 4 ms 596 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 3 ms 596 KB Output is correct
35 Correct 2 ms 596 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Incorrect 4 ms 1452 KB WA in grader: Too many instructions
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 340 KB on inputs (0, 0), (0, 1), expected 1, but computed 0
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1236 KB on inputs (80, 199), (81, 199), expected 1, but computed 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 272 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 300 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 1 ms 304 KB Output is correct
22 Correct 0 ms 300 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 300 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 4 ms 596 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 3 ms 596 KB Output is correct
35 Correct 2 ms 596 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Incorrect 4 ms 1452 KB WA in grader: Too many instructions
39 Halted 0 ms 0 KB -