fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. int main(){
  5. ll n,m; cin>>n>>m;
  6. while(m--){
  7. ll r,c; cin>>r>>c;
  8. set<pair<ll, ll>> a;
  9. bool cancel=false;
  10. for(int i=r-1; i<=r+1; i++){
  11. for(int j=c-1; j<=c+1; j++){
  12. if(a.count({i,j})) cancel=true;
  13. }
  14. }
  15. if(!cancel) a.insert({r,c});
  16. cout<<a.size()<<endl;
  17. }
  18. }
Success #stdin #stdout 0.01s 5320KB
stdin
4 3
1 1
2 2
2 3
stdout
1
1
1