Submission #333442

#TimeUsernameProblemLanguageResultExecution timeMemory
333442luanaamorimTracks in the Snow (BOI13_tracks)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <queue> using namespace std; char tab[4002][4002]; int n, m, f, r, ans, passou[4002][4002], passou2[4002][4002]; queue<pair<int, int> > fila; void bfs1(int a, int b) { fila.push(make_pair(a, b)); while (!fila.empty()) { int a = fila.front().first, b = fila.front().second; fila.pop(); if (tab[a][b] != 'F' || passou[a][b] != -1) continue; passou[a][b] = 1; fila.push(make_pair(a + 1, b)); fila.push(make_pair(a - 1, b)); fila.push(make_pair(a, b + 1)); fila.push(make_pair(a, b - 1)); } } void bfs2(int a, int b) { fila.push(make_pair(a, b)); passou[a][b] = 1; while (!fila.empty()) { int a = fila.front().first, b = fila.front().second; fila.pop(); if (a < 0 || b < 0 || a > n - 1 || b > m - 1) continue; if (tab[a][b] == '.' || passou2[a][b]) continue; passou2[a][b] = 1; fila.push(make_pair(a + 1, b)); fila.push(make_pair(a - 1, b)); fila.push(make_pair(a, b + 1)); fila.push(make_pair(a, b - 1)); } } int main() { cin >> n >> m; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> tab[i][j]; memset(passou, -1, sizeof(passou)); memset(passou2, -1, sizeof(passou2)); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { if (tab[i][j] == 'F' && !passou[i][j]) bfs1(i, j), ans++; if (tab[i][j] == 'R' && !passou2[i][j]) bfs2(i, j), ans++; } cout << ans << endl; }

Compilation message (stderr)

tracks.cpp: In function 'int main()':
tracks.cpp:49:5: error: 'memset' was not declared in this scope
   49 |     memset(passou, -1, sizeof(passou));
      |     ^~~~~~
tracks.cpp:3:1: note: 'memset' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
    2 | #include <queue>
  +++ |+#include <cstring>
    3 |