Submission #800437

# Submission time Handle Problem Language Result Execution time Memory
800437 2023-08-01T14:55:42 Z tlnk07 Dijamant (COCI22_dijamant) C++17
70 / 70
96 ms 8044 KB
#include<bits/stdc++.h>
using namespace std;

long long n, m, cnt = 0, temp;
bool grid[2001][2001];
string s;

int main()
{
	cin >> n >> m;
	for(int i = 1; i <= n; ++i)
	{
		cin >> s;
		for(int j = 0; j < m; ++j)	if(s[j] == '#')	grid[i][j + 1] = true;
	}
	for(int i = 1; i < n; ++i)
	{
		for(int j = 2; j < m; ++j)
		{
			if(grid[i][j])
			{
				temp = -1;
				bool check = 0, done = 0;
				for(int k = 1; k <= n; ++k)
				{
					if(grid[i + k][j - k]  == grid[i + k][j + k] && grid[i + k][j - k])
					{
						for(int l = j - k + 1; l < j + k; ++l)
						{
							if(grid[i + k][l])
							{
								check = 1;
								break;
							}
						}
						if(check)
						{
							if(grid[i + k][j - k + 2] == grid[i + k][j + k - 2] && grid[i + k][j - k + 2])
							{
								done = 1;
								temp = k - 1;
								check = 0;
								if(temp < 1)	check = 1;
							}
						}
					}
					else if(grid[i + k][j - k + 2] == grid[i + k][j + k - 2] && grid[i + k][j - k + 2])
					{
						done = 1;
						temp = k - 1;
						if(temp < 1)	check = 1;
					}
					else	check = 1;
					if(check || done)	break;
				}
				if(done)
				{
					if(temp + i > n)
					{
						check = 1;
						continue;
					}
					int temp2 = temp - 1;
					while(temp2 >= 0)
					{
						if(grid[i + temp * 2 - temp2][j - temp2] == grid[i + temp * 2 - temp2][j + temp2] && grid[i + temp * 2 - temp2][j - temp2])
						{
							for(int l = j - temp2 + 1; l < j + temp2; ++l)
							{
								if(grid[i + temp * 2 - temp2][l])
								{
									check = 1;
									break;
								}
							}
						}
						else	check = 1;
						if(check)	break;
						--temp2;
					}
				}
				if(!check && done)
				{
					++cnt;
				}
			}
		}
	}
	cout << cnt << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 448 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 448 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 61 ms 3888 KB Output is correct
15 Correct 72 ms 7568 KB Output is correct
16 Correct 96 ms 7376 KB Output is correct
17 Correct 66 ms 7408 KB Output is correct
18 Correct 83 ms 8044 KB Output is correct
19 Correct 58 ms 7096 KB Output is correct
20 Correct 66 ms 7916 KB Output is correct
21 Correct 61 ms 7076 KB Output is correct
22 Correct 77 ms 7544 KB Output is correct
23 Correct 72 ms 7072 KB Output is correct
24 Correct 78 ms 7604 KB Output is correct
25 Correct 59 ms 4468 KB Output is correct
26 Correct 69 ms 7224 KB Output is correct