답안 #390178

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
390178 2021-04-15T13:52:34 Z SuhaibSawalha1 Vision Program (IOI19_vision) C++17
66 / 100
897 ms 7152 KB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;

int dist (array<int, 2> a, array<int, 2> b) {
	return abs(a[0] - b[0]) + abs(a[1] - b[1]);
}

void construct_network(int n, int m, int k) {
	auto val = [&] (int i, int j) {
		return i * m + j;
	};
	vector<int> OR;
	int cur = n * m - 1;
	if (k == 1) {
		int row[n], col[m];
		int xor_for_rows, xor_for_cols;
		vector<int> ask_r, ask_c;
		for (int i = 0; i < n; ++i) {
			vector<int> p;
			for (int j = 0; j < m; ++j) {
				p.push_back(val(i, j));
			}
			add_or(p);
			row[i] = ++cur;
			ask_r.push_back(cur);
		}
		for (int j = 0; j < m; ++j) {
			vector<int> p;
			for (int i = 0; i < n; ++i) {
				p.push_back(val(i, j));
			}
			add_or(p);
			col[j] = ++cur;
			ask_c.push_back(cur);
		}
		add_xor(ask_r);
		xor_for_rows = ++cur;
		add_xor(ask_c);
		xor_for_cols = ++cur;
		for (int i = 1; i < n; ++i) {
			add_and({row[i - 1], row[i], xor_for_cols});
			OR.push_back(++cur);
		}
		for (int i = 1; i < m; ++i) {
			add_and({col[i - 1], col[i], xor_for_rows});
			OR.push_back(++cur);
		}
	}
	else {
		int q = 1e4 - 1;
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				vector<int> ask;
				for (int h = i; h < n; ++h) {
					for (int w = (i == h ? j : 0); w < m; ++w) {
						if (dist({i, j}, {h, w}) == k && q) {
							ask.push_back(val(h, w));
						}
					}
				}
				if (ask.size() && q > 2) {
					ask.push_back(val(i, j));
					add_xor(ask), ++cur;
					add_not(cur), ++cur;
					add_and({val(i, j), cur}); ++cur;
					q -= 3;
					OR.push_back(cur);
				}
			}
		}
	}
	add_or(OR);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 300 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 296 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 300 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 296 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 5 ms 588 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 5 ms 588 KB Output is correct
35 Correct 4 ms 588 KB Output is correct
36 Correct 2 ms 332 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 300 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 296 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 5 ms 588 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 5 ms 588 KB Output is correct
35 Correct 4 ms 588 KB Output is correct
36 Correct 2 ms 332 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Incorrect 95 ms 3140 KB on inputs (58, 84), (89, 65), expected 1, but computed 0
39 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 292 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 19 ms 1352 KB Output is correct
5 Correct 14 ms 964 KB Output is correct
6 Correct 10 ms 592 KB Output is correct
7 Correct 8 ms 204 KB Output is correct
8 Correct 3 ms 332 KB Output is correct
9 Correct 47 ms 2488 KB Output is correct
10 Correct 49 ms 1832 KB Output is correct
11 Correct 27 ms 960 KB Output is correct
12 Correct 19 ms 288 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 296 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 296 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 6 ms 716 KB Output is correct
21 Correct 266 ms 4064 KB Output is correct
22 Correct 258 ms 3364 KB Output is correct
23 Correct 221 ms 280 KB Output is correct
24 Correct 6 ms 716 KB Output is correct
25 Correct 240 ms 3764 KB Output is correct
26 Correct 211 ms 204 KB Output is correct
27 Correct 11 ms 1100 KB Output is correct
28 Correct 897 ms 5840 KB Output is correct
29 Correct 866 ms 7152 KB Output is correct
30 Correct 832 ms 2516 KB Output is correct
31 Correct 825 ms 280 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 1136 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 6 ms 716 KB Output is correct
8 Correct 6 ms 716 KB Output is correct
9 Correct 10 ms 1040 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 300 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 296 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 5 ms 588 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 5 ms 588 KB Output is correct
35 Correct 4 ms 588 KB Output is correct
36 Correct 2 ms 332 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Incorrect 95 ms 3140 KB on inputs (58, 84), (89, 65), expected 1, but computed 0
39 Halted 0 ms 0 KB -