# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
659437 |
2022-11-17T18:12:55 Z |
Kenpar |
Zoo (COCI19_zoo) |
C++17 |
|
1 ms |
340 KB |
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define endl '\n'
const ll MOD = 1e9+7;
const ll INF = 1e16;
const ll MAX = 2 * 1e5;
char arr[1001][1001];
int numArr[1001][1001];
int n,m;
void DFS(int i, int j, int num, char parent){
if(i < 0 || i >= n) return;
if(j < 0 || j >= m) return;
if(arr[i][j] != parent) return;
if(numArr[i][j] != 0) return;
numArr[i][j] = num;
DFS(i-1, j, num, parent);
DFS(i+1, j, num, parent);
DFS(i, j+1, num, parent);
DFS(i, j-1, num, parent);
}
void solve(){
cin>>n>>m;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cin>>arr[i][j];
numArr[i][j] = 0;
}
}
int cur = 1;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
if(numArr[i][j] == 0 && arr[i][j] != '*'){
DFS(i,j,cur,arr[i][j]);
cur++;
}
}
}
cout<<cur-1;
}
int main()
{
cin.tie(NULL);
ios::sync_with_stdio(NULL);
int t = 1;
//cin >> t;
while(t--){
//cout<<"Case #"<<t<<" > "<<endl;
solve();
cout<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |