Language: C++

#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>

int main(){
  while(1){
    int h,w;
    cin>>w>>h;
    if(h==0&&w==0) break;
    char a[h][w];
    queue<pair<int,int>> q;
    bool used[h][w];
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin>>a[i][j];
        used[i][j]=0;
        if(a[i][j]=='@') q.push(make_pair(i,j));
      }
    }
    int ans=0;
    while(!q.empty()){
      pair<int,int> p=q.front();
      q.pop();
      int x=p.first, y=p.second;
      if(used[x][y]) continue;
      used[x][y]=1;
      ans++;
      if(x>0){
        if(!used[x-1][y]&&a[x-1][y]=='.'){
          q.push(make_pair(x-1,y));
        }
      }
      if(x<h-1){
        if(!used[x+1][y]&&a[x+1][y]=='.'){
          q.push(make_pair(x+1,y));
        }
      }
      if(y>0){
        if(!used[x][y-1]&&a[x][y-1]=='.'){
          q.push(make_pair(x,y-1));
        }
      }
      if(y<w-1){
        if(!used[x][y+1]&&a[x][y+1]=='.'){
          q.push(make_pair(x,y+1));
        }
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:22:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   22 |     cin>>w>>h;
      |     ^~~
      |     std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:25:5: error: 'queue' was not declared in this scope; did you mean 'std::queue'?
   25 |     queue<pair<int,int>> q;
      |     ^~~~~
      |     std::queue
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:5:
/usr/include/c++/14/bits/stl_queue.h:96:11: note: 'std::queue' declared here
   96 |     class queue
      |           ^~~~~
a.cc:25:11: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   25 |     queue<pair<int,int>> q;
      |           ^~~~
      |           std::pair
In file included from /usr/include/c++/14/string:48,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/bits/stl_iterator.h:3013:12: note: 'std::pair' declared here
 3013 |     struct pair;
      |            ^~~~
a.cc:25:16: error: expected primary-expression before 'int'
   25 |     queue<pair<int,int>> q;
      |                ^~~
a.cc:31:26: error: 'q' was not declared in this scope
   31 |         if(a[i][j]=='@') q.push(make_pair(i,j));
      |                          ^
a.cc:31:33: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
   31 |         if(a[i][j]=='@') q.push(make_pair(i,j));
      |                                 ^~~~~~~~~
      |                                 std::make_pair
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
a.cc:35:12: error: 'q' was not declared in this scope
   35 |     while(!q.empty()){
      |            ^
a.cc:36:12: error: expected primary-expression before 'int'
   36 |       pair<int,int> p=q.front();
      |            ^~~
a.cc:38:13: error: 'p' was not declared in this scope
   38 |       int x=p.first, y=p.second;
      |             ^
a.cc:39:18: error: 'y' was not declared in this scope
   39 |       if(used[x][y]) continue;
      |                  ^
a.cc:40:15: error: 'y' was not declared in this scope
   40 |       used[x][y]=1;
      |               ^
a.cc:44:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
   44 |           q.push(make_pair(x-1,y));
      |                  ^~~~~~~~~
      |                  std::make_pair
/usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
a.cc:49:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
   49 |           q.push(make_pair(x+1,y));
      |                  ^~~~~~~~~
      |                  std::make_pair
/usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
a.cc:54:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
   54 |           q.push(make_pair(x,y-1));
      |                  ^~~~~~~~~
      |                  std::make_pair
/usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
a.cc:59:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
   59 |           q.push(make_pair(x,y+1));
      |                  ^~~~~~~~~
      |                  std::make_pair
/usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
a.cc:63:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   63 |     cout<<ans<<endl;
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:63:16: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   63 |     cout<<ans<<endl;
      |                ^~~~
      |                std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~