LCOV - code coverage report
Current view: top level - 04 - b.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 16 16
Test Date: 2025-10-12 18:20:59 Functions: 100.0 % 1 1
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 100.0 % 26 26

             Branch data     Line data    Source code
       1                 :             : #include <iostream>
       2                 :             : #include <fstream>
       3                 :             : #include <vector>
       4                 :             : #include <string>
       5                 :             : #include <iterator>
       6                 :             : using namespace std;
       7                 :             : 
       8                 :           2 : int main() {
       9                 :           2 :   ifstream inputFile("input.txt");
      10         [ +  + ]:           2 :   if (!inputFile) {
      11                 :           1 :     cerr << "Error: Could not open input file.\n";
      12                 :           1 :     return 1;
      13                 :             :   }
      14                 :           3 :   vector<string> grid{istream_iterator<string>(inputFile), {}};
      15                 :           1 :   int count = 0;
      16                 :             : 
      17         [ +  + ]:         139 :   for (int row = 1; row < grid.size() - 1; ++row) {
      18         [ +  + ]:       19182 :     for (int col = 1; col < grid[0].size() - 1; ++col) {
      19         [ +  + ]:       23905 :       count += grid[row][col] == 'A' &&
      20   [ +  +  +  + ]:        4861 :                ((grid[row - 1][col - 1] == 'M' && grid[row + 1][col + 1] == 'S' ||
      21   [ +  +  +  + ]:        3549 :                  grid[row - 1][col - 1] == 'S' && grid[row + 1][col + 1] == 'M') &&
      22   [ +  +  +  + ]:        2819 :                 (grid[row - 1][col + 1] == 'M' && grid[row + 1][col - 1] == 'S' ||
      23   [ +  +  +  + ]:        1890 :                  grid[row - 1][col + 1] == 'S' && grid[row + 1][col - 1] == 'M'));
      24                 :             :     }
      25                 :             :   }
      26                 :           1 :   cout << count << endl;
      27         [ +  + ]:           3 : }
        

Generated by: LCOV version 2.0-1