# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
725466 |
2023-04-17T13:32:57 Z |
TheSahib |
Zoo (COCI19_zoo) |
C++17 |
|
0 ms |
340 KB |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll long long
#define pii pair<int, int>
using namespace std;
const int MAX = 1005;
pii dirs[4] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int n, m;
int grid[MAX][MAX];
bool visited[MAX][MAX];
void dfs(pii cord){
visited[cord.first][cord.second] = 1;
for(pii d:dirs){
pii cord1 = {cord.first + d.first, cord.second + d.second};
if(cord1.first >= 0 && cord1.first < n && cord1.second >= 0 && cord1.second < m &&
!visited[cord1.first][cord1.second] && grid[cord1.first][cord1.second] == grid[cord.first][cord.second]){
dfs(cord1);
}
}
}
int main(){
cin >> n >> m;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
char c; cin >> c;
if(c == 'B'){
grid[i][j] = 1;
}
else if(c == 'T'){
grid[i][j] = 2;
}
}
}
int ans = 0;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
if(grid[i][j] && !visited[i][j]){
++ans;
dfs({i, j});
}
}
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |