---
# System prepended metadata

title: 20191214TOI新手同好會5.卷積神經網路

---

# 20191214TOI新手同好會5.卷積神經網路

---

題目連結：https://zerojudge.tw/ShowProblem?problemid=e798

---

```clike=
#include<iostream>
using namespace std;

int main(){
	int n, max, x = 0, y = 0;
	int layer[20][20];
	int ans[10][10];
	cin >> n;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++)
			cin >> layer[i][j];
	}
	for(int i = 0; i < n; i = i + 2){
		x = 0;
		for(int j = 0; j < n; j = j + 2){
			max = layer[i][j];
			for(int k = i; k < i + 2; k++){
				for(int p = j; p < j + 2; p++){
					if(layer[k][p] >= max){
						max = layer[k][p];
						ans[y][x] = layer[k][p];
					}
				}
			}
			x++;
		}
		y++;
	}
	for(int i = 0; i < y; i++){
		for(int j = 0; j < x; j++)
			cout << ans[i][j] << " ";
		cout << endl;
	}
	return 0;
} 
```

---

解題想法：
定點只抓2×2的左上角那一格，再去做2×2內部大小比較