Submission
Status:
[PP-SSSSSSSSSSSS]
Subtask/Task Score:
{0/100}
Score: 0
User: Quaoar
Problemset: fireball
Language: cpp
Time: 0.003 second
Submitted On: 2025-12-10 12:35:15
#include <iostream>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int map[100][100];
int n , m ,q;
int cnt = 0;
cin >> n >> m >> q;
for (int i = 0 ; i < n ; i++){
for (int j = 0 ; j < m ; j++){
cin >> map[i][j];
if (map[i][j] == 1){
cnt++;
}
}
}
for (int i = 0 ; i < q ; i++){
int x , y;
cin >> x >> y;
x--;
y--;
//cout << map[x][y];
if (map[x][y] == 0){
cout << cnt << "\n";
continue;
}
for (int ny = -1 ; ny <= 1 ; ny++){
if (y + ny < 0 || y + ny >= m ){
continue;
}
if (map[x][y + ny] == 1){
map[x][y + ny] = 0;
cnt--;
}
}
for (int nx = -1 ; nx <= 1 ; nx++){
if (x + nx < 0 || x + nx >= n ){
continue;
}
if (map[x + nx][y] == 1){
map[x + nx][y] = 0;
cnt--;
}
}
cout << cnt << "\n";
}
return 0;
}