Submission #618216

# Submission time Handle Problem Language Result Execution time Memory
618216 2022-08-02T03:17:21 Z joelau Vision Program (IOI19_vision) C++14
66 / 100
9 ms 1144 KB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
 
void construct_network(int H, int W, int K) {
	if (max(H,W) <= 30 || min(H,W) == 1) {
		vector<int> A;
		for (int i = 0; i < H; ++i) for (int j = 0; j < W; ++j) {
			vector<int> V;
			if (i+K < H) V.push_back((i+K)*W+j);
			if (i-K >= 0) V.push_back((i-K)*W+j);
			if (j+K < W) V.push_back(i*W+j+K);
			if (j-K >= 0) V.push_back(i*W+j-K);
			for (int x = 1; x < K; ++x) {
				int y = K-x;
				if (i+x < H && j+y < W) V.push_back((i+x)*W+j+y);
				if (i+x < H && j-y >= 0) V.push_back((i+x)*W+j-y);
				if (i-x >= 0 && j+y < W) V.push_back((i-x)*W+j+y);
				if (i-x >= 0 && j-y >= 0) V.push_back((i-x)*W+j-y);
			}
			if (!V.empty()) {
				add_or(V);
				A.push_back(i*W+j);
			}
		}
		for (int i = 0; i < A.size(); ++i) add_and({A[i],H*W+i});
		vector<int> V;
		for (int i = 0; i < A.size(); ++i) V.push_back(H*W+A.size()+i);
		add_or(V);
	}
	else if (K == 1) {
		for (int i = 0; i < H; ++i) {
			vector<int> V;
			for (int j = 0; j < W; ++j) V.push_back(i*W+j);
			add_or(V);
		}
		for (int i = 0; i < H-1; ++i) add_and({H*W+i,H*W+i+1});
		for (int j = 0; j < W; ++j) {
			vector<int> V;
			for (int i = 0; i < H; ++i) V.push_back(i*W+j);
			add_or(V);
		}
		for (int i = 0; i < W-1; ++i) add_and({H*W+H*2-1+i,H*W+H*2-1+i+1});
		vector<int> V;
		for (int i = 0; i < H; ++i) V.push_back(H*W+i);
		add_xor(V);
		V.clear();
		for (int i = 0; i < H-1; ++i) V.push_back(H*W+H+i);
		add_xor(V);
		V.clear();
		for (int i = 0; i < W; ++i) V.push_back(H*W+H*2-1+i);
		add_xor(V);
		V.clear();
		for (int i = 0; i < W-1; ++i) V.push_back(H*W+H*2-1+W+i);
		add_xor(V);
		int n = H*W+H*2+W*2-2;
		add_and({n,n+3});
		add_and({n+1,n+2});
		add_or({n+4,n+5});
	}
	else {
		vector<int> V;
		for (int x = 0; x <= K; ++x) {
			int y = K-x;
			if (x < H && y < W) V.push_back(x*W+y);
		}
		add_or(V);
	}
}

Compilation message

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:26:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for (int i = 0; i < A.size(); ++i) add_and({A[i],H*W+i});
      |                   ~~^~~~~~~~~~
vision.cpp:28:21: 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 < A.size(); ++i) V.push_back(H*W+A.size()+i);
      |                   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 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 0 ms 300 KB Output is correct
15 Correct 0 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 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 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 0 ms 300 KB Output is correct
15 Correct 0 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 0 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 1 ms 212 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 1 ms 340 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 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 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 0 ms 300 KB Output is correct
15 Correct 0 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 0 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 1 ms 212 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 1 ms 340 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 296 KB Output is correct
28 Correct 4 ms 596 KB Output is correct
29 Correct 1 ms 352 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 296 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 5 ms 596 KB Output is correct
35 Correct 4 ms 468 KB Output is correct
36 Correct 1 ms 300 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 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 0 ms 300 KB Output is correct
15 Correct 0 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 0 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 1 ms 212 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 1 ms 340 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 296 KB Output is correct
28 Correct 4 ms 596 KB Output is correct
29 Correct 1 ms 352 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 296 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 5 ms 596 KB Output is correct
35 Correct 4 ms 468 KB Output is correct
36 Correct 1 ms 300 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Incorrect 1 ms 304 KB on inputs (8, 61), (22, 97), expected 1, but computed 0
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 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 300 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 300 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 1 ms 300 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 296 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 304 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 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 296 KB Output is correct
18 Correct 1 ms 296 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 5 ms 680 KB Output is correct
21 Correct 1 ms 296 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 5 ms 724 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 9 ms 1144 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 300 KB Output is correct
30 Correct 1 ms 296 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1092 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 4 ms 724 KB Output is correct
8 Correct 5 ms 724 KB Output is correct
9 Correct 8 ms 1064 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 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 0 ms 300 KB Output is correct
15 Correct 0 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 0 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 1 ms 212 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 1 ms 340 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 296 KB Output is correct
28 Correct 4 ms 596 KB Output is correct
29 Correct 1 ms 352 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 296 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 5 ms 596 KB Output is correct
35 Correct 4 ms 468 KB Output is correct
36 Correct 1 ms 300 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Incorrect 1 ms 304 KB on inputs (8, 61), (22, 97), expected 1, but computed 0
39 Halted 0 ms 0 KB -