답안 #237056

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
237056 2020-06-04T10:42:01 Z MrRobot_28 Tetris (COCI17_tetris) C++17
80 / 80
5 ms 384 KB
#include<bits/stdc++.h>
using namespace std;

signed main() {
	int n, m;
	cin >> n >> m;
	vector <vector <char> > A(n, vector <char> (m));
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			cin >> A[i][j];
		}
	}
	vector <int> ans(5);
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			if(A[i][j] == '.')
			{
				continue;
			}
			if(i > 0 && j > 0 && A[i][j] == A[i - 1][j] && A[i - 1][j] == A[i][j - 1] && A[i - 1][j - 1] == A[i][j])
			{
				ans[0]++;
			}
			if(i > 2 && A[i - 3][j] == A[i][j] && A[i - 2][j] == A[i][j] && A[i - 1][j] == A[i][j])
			{
				ans[1]++;
			}
			if(j > 2 && A[i][j - 3] == A[i][j] && A[i][j - 2] == A[i][j] && A[i][j - 1] == A[i][j])
			{
				ans[1]++;
			}
			if(i > 1 && j > 0 && A[i - 1][j] == A[i][j] && A[i - 1][j - 1] == A[i][j] && A[i - 2][j - 1] == A[i][j])
			{
				ans[2]++;
			}
			if(i < n - 1 && j > 1 && A[i][j - 1] == A[i][j] && A[i + 1][j - 1] == A[i][j] && A[i + 1][j - 2] == A[i][j])
			{
				ans[2]++;
			}
			if(i > 0 && j > 1 && A[i][j - 1] == A[i][j] && A[i - 1][j - 1] == A[i][j] && A[i - 1][j - 2] == A[i][j])
			{
				ans[3]++;
			}
			if(i > 1 && j < m - 1 && A[i - 1][j] == A[i][j] && A[i -1 ][j + 1] == A[i][j] && A[i - 2][j + 1] == A[i][j])
			{
				ans[3]++;
			}
			if(i > 0 && j > 0 && i < n - 1 && A[i - 1][j] == A[i][j] && A[i + 1][j] == A[i][j] && A[i][j - 1] == A[i][j])
			{
				ans[4]++;
			}
			if(i > 0 && j > 0 && j < m - 1 && A[i - 1][j] == A[i][j] && A[i][j - 1] == A[i][j] && A[i][j + 1] == A[i][j])
			{
				ans[4]++;
			}
			if(i < n - 1  && j > 0 && j < m - 1 && A[i][j] == A[i + 1][j] && A[i][j - 1] == A[i][j] && A[i][j + 1] == A[i][j])
			{
				ans[4]++;
			}
			if(i > 0 && i < n - 1 && j < m - 1 && A[i][j] == A[i - 1][j] && A[i][j] == A[i][j + 1] && A[i][j] == A[i + 1][j])
			{
				ans[4]++;
			}
		}
	}
	for(int i = 0; i < 5; i++)
	{
		cout << ans[i] << "\n";
	}
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct