Submission
Status:
[-SSSSSSSSSSSSSS]
Subtask/Task Score:
{0/100}
Score: 0
User: APNICHANAN
Problemset: fireball
Language: cpp
Time: 0.002 second
Submitted On: 2026-03-14 14:22:22
#include <bits/stdc++.h>
using namespace std;
int a[105][105];
int dx[5] = {1, -1, 0, 0, 0}, dy[5] = {0, 0, 1, -1, 0};
int main()
{
int n, m, q, cnt = 0;
cin >> n >> m >> q;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
cin >> a[i][j];
if (a[i][j] == 1)
cnt++;
}
}
int tmp = cnt;
for (int i = 0; i < q; i++)
{
cnt = tmp;
int x, y;
cin >> x >> y;
for (int j = 0; j < 5; j++)
{
if (x + dx[j] < 1 || x + dx[j] > n || y + dy[j] < 1 || y + dy[j] > m)
continue;
if (a[x + dx[j]][y + dy[j]] == 1)
{
cnt--;
}
}
cout << cnt << "\n";
}
}