Извините, не вышло почему, то нормально вставить
Код:
#include <iostream>
#include <fstream>
int main()
{
int board[10][10] = {0};
std::ifstream input("input.txt");
int n;
int x, y;
input >> n;
for (int i = 0; i < n; ++i)
{
input >> x >> y;
board[x][y] = 1;
}
input.close();
int p = 0;
for (int i = 1; i < 9; ++i)
{
for (int j = 1; j < 9; ++j)
{
if (board[i][j] == 1)
{
if (board[i - 1][j] == 0)
++p;
if (board[i][j + 1] == 0)
++p;
if (board[i + 1][j] == 0)
++p;
if (board[i][j - 1] == 0)
++p;
}
}
}
std::ofstream output("output.txt");
output << p;
output.close();
return 0;