# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
440490 | MahfuzAhmed | Emacs (COCI20_emacs) | C++14 | 1 ms | 344 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* 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... |