# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
440490 | MahfuzAhmed | Emacs (COCI20_emacs) | C++14 | 1 ms | 344 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
* author: mahfuzz
* created: 02.07.2021
**/
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define all(p) p.begin(),p.end()
typedef long long ll;
const int maxn = 200;
int mat[maxn][maxn];
int x[] = {0, 0, -1, 1};
int y[] = {-1, 1, 0, 0};
int main(int argc, char* argv[]){
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
int n, m; cin >> n >> m;
char grid[n + 1][m + 1];
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin >> grid[i][j];
}
}
int cnt = 0;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(grid[i][j] == '*'){
bool flag = false;
for(int k = 0; k < 4 && !flag; k++){
int xx = i + x[k];
int yy = j + y[k];
if(mat[xx][yy] != 0){
mat[i][j] = mat[xx][yy];
flag = true;
}
}
if(!flag){
++cnt;
mat[i][j] = cnt;
}
}
}
}
cout << cnt << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |