# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
731417 |
2023-04-27T12:01:50 Z |
eneskav |
Emacs (COCI20_emacs) |
C++17 |
|
0 ms |
0 KB |
#include <iostream>
#include <queue>
#define int long long
using namespace std;
int dx[4] = {0, 0, -1, 1};
int dy[4] = {-1, 1, 0, 0};
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, m;
cin >> n >> m;
bool a[n][m];
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < m; ++j)
{
char c;
cin >> c;
a[i][j] = (c == '.');
}
}
int ans = 0;
bool vis[n][m];
memset(vis, false, sizeof(vis));
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < m; ++j)
{
if (vis[i][j])
continue;
if (a[i][j])
continue;
queue<pair<int, int> > q;
q.push(make_pair(i, j));
while (!q.empty())
{
pair<int, int> p = q.front();
q.pop();
int x = p.first, y = p.second;
if (vis[x][y])
continue;
vis[x][y] = true;
for (int k = 0; k < 4; ++k)
{
int nx = x + dx[k], ny = y + dy[k];
if (nx < 0 || nx >= n || ny < 0 || ny >= m)
continue;
if (a[nx][ny])
continue;
q.push(make_pair(nx, ny));
}
}
++ans;
}
}
cout << ans;
}
Compilation message
emacs.cpp: In function 'int main()':
emacs.cpp:27:5: error: 'memset' was not declared in this scope
27 | memset(vis, false, sizeof(vis));
| ^~~~~~
emacs.cpp:3:1: note: 'memset' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
2 | #include <queue>
+++ |+#include <cstring>
3 | #define int long long