답안 #298533

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
298533 2020-09-13T04:58:08 Z JPN20 Vision Program (IOI19_vision) C++17
58 / 100
11 ms 1276 KB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> t1[209];
vector<int> t2[209];

void Reigai(int H, int W, int K) {
	vector<int> vec;
	int cnt = H * W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			for (int k = 0; k < H; k++) {
				for (int l = 0; l < W; l++) {
					if (abs(i - k) + abs(j - l) != K) continue;
					int c1 = i * W + j;
					int c2 = k * W + l;
					if (c1 > c2) continue;
					add_and(vector<int>{c1, c2});
					vec.push_back(cnt);
					cnt++;
				}
			}
		}
	}
	add_or(vec);
}

void solve_Subtask5(int H, int W, int K) {
	for (int i = 0; i < 208; i++) t1[i].clear();
	for (int i = 0; i < 208; i++) t2[i].clear();
	int cnt = H * W + H + W;
	
	// Step #A. Tate
	int milestone1 = cnt;
	for (int i = 0; i < H; i++) {
		for (int j = i + 1; j < H; j++) {
			int c1 = H * W + i;
			int c2 = H * W + j;
			t1[j - i].push_back(cnt);
			add_and(vector<int>{c1, c2});
			cnt++;
		}
	}
	
	// Step #B. Yoko
	int milestone2 = cnt;
	for (int i = 0; i < W; i++) {
		for (int j = i + 1; j < W; j++) {
			int c1 = H * W + H + i;
			int c2 = H * W + H + j;
			t2[j - i].push_back(cnt);
			add_and(vector<int>{c1, c2});
			cnt++;
		}
	}
	vector<int> d1; for (int i = 0; i < H; i++) d1.push_back(H * W + i);
	vector<int> d2; for (int i = 0; i < W; i++) d2.push_back(H * W + H + i);
	
	// Step #C. Tate Diff
	int milestone3 = cnt;
	add_xor(d1); cnt++;
	for (int i = 1; i < H; i++) { add_or(t1[i]); cnt++; }
	
	// Step #D. Yoko Diff
	int milestone4 = cnt;
	add_xor(d2); cnt++;
	for (int i = 1; i < W; i++) { add_or(t2[i]); cnt++; }
	
	// Step #E. Final Sum
	int milestone5 = cnt;
	vector<int> finale;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (i + j != K) continue;
			finale.push_back(cnt);
			add_and(vector<int>{milestone3 + i, milestone4 + j});
			cnt++;
		}
	}
	add_or(finale);
}

void solve_Subtask7(int H, int W) {
	for (int i = 0; i < H - 1; i++) {
		int c1 = H * W + i;
		int c2 = H * W + (i + 1);
		add_and(vector<int>{c1, c2});
	}
	for (int i = 0; i < W - 1; i++) {
		int c1 = H * W + H + i;
		int c2 = H * W + H + (i + 1);
		add_and(vector<int>{c1, c2});
	}
	int base = H * W + H + W + (H - 1) + (W - 1);
	vector<int> d1; for (int i = 0; i < H; i++) d1.push_back(H * W + i);
	vector<int> d2; for (int i = 0; i < W; i++) d2.push_back(H * W + H + i);
	vector<int> d3; for (int i = 0; i < H - 1; i++) d3.push_back(H * W + H + W + i);
	vector<int> d4; for (int i = 0; i < W - 1; i++) d4.push_back(H * W + H + W + (H - 1) + i);
	add_xor(d1);
	add_xor(d2);
	add_xor(d3);
	add_xor(d4);
	add_and(vector<int>{base + 0, base + 3});
	add_and(vector<int>{base + 1, base + 2});
	add_or(vector<int>{base + 4, base + 5});
}

void construct_network(int H, int W, int K) {
	if (H == 1 || W == 1) {
		Reigai(H, W, K);
		return;
	}
		
	// Step #1. Yoko
	for (int i = 0; i < H; i++) {
		vector<int> vec;
		for (int j = 0; j < W; j++) vec.push_back(i * W + j);
		add_or(vec);
	}
	
	// Step #2. Tate
	for (int i = 0; i < W; i++) {
		vector<int> vec;
		for (int j = 0; j < H; j++) vec.push_back(j * W + i);
		add_or(vec);
	}
	
	if (K == 1) solve_Subtask7(H, W);
	if (K >= 2) solve_Subtask5(H, W, K);
}

Compilation message

vision.cpp: In function 'void solve_Subtask5(int, int, int)':
vision.cpp:35:6: warning: unused variable 'milestone1' [-Wunused-variable]
   35 |  int milestone1 = cnt;
      |      ^~~~~~~~~~
vision.cpp:47:6: warning: unused variable 'milestone2' [-Wunused-variable]
   47 |  int milestone2 = cnt;
      |      ^~~~~~~~~~
vision.cpp:71:6: warning: unused variable 'milestone5' [-Wunused-variable]
   71 |  int milestone5 = cnt;
      |      ^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 1 ms 256 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 1 ms 256 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
38 Incorrect 3 ms 1276 KB WA in grader: Too many instructions
39 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 288 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 5 ms 892 KB Output is correct
5 Correct 5 ms 892 KB Output is correct
6 Correct 6 ms 892 KB Output is correct
7 Correct 5 ms 892 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Incorrect 2 ms 1148 KB WA in grader: Too many instructions
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1152 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 416 KB Output is correct
7 Correct 6 ms 768 KB Output is correct
8 Correct 6 ms 768 KB Output is correct
9 Correct 11 ms 1152 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 1 ms 256 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
38 Incorrect 3 ms 1276 KB WA in grader: Too many instructions
39 Halted 0 ms 0 KB -