Language: C++

#include <bits/stdc++.h>
#define REP(i,a) for(int i=0;i<(a);i++)
#define MOD 1000000007

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:8:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 |     cin>>w>>h;
      |     ^~~
      |     std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 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:11:5: error: 'queue' was not declared in this scope; did you mean 'std::queue'?
   11 |     queue<pair<int,int>> q;
      |     ^~~~~
      |     std::queue
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157:
/usr/include/c++/14/bits/stl_queue.h:96:11: note: 'std::queue' declared here
   96 |     class queue
      |           ^~~~~
a.cc:11:11: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   11 |     queue<pair<int,int>> q;
      |           ^~~~
      |           std::pair
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:89:12: note: 'std::pair' declared here
   89 |     struct pair;
      |            ^~~~
a.cc:11:16: error: expected primary-expression before 'int'
   11 |     queue<pair<int,int>> q;
      |                ^~~
a.cc:17:26: error: 'q' was not declared in this scope
   17 |         if(a[i][j]=='@') q.push(make_pair(i,j));
      |                          ^
a.cc:17:33: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
   17 |         if(a[i][j]=='@') q.push(make_pair(i,j));
      |                                 ^~~~~~~~~
      |                                 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:21:12: error: 'q' was not declared in this scope
   21 |     while(!q.empty()){
      |            ^
a.cc:22:12: error: expected primary-expression before 'int'
   22 |       pair<int,int> p=q.front();
      |            ^~~
a.cc:24:13: error: 'p' was not declared in this scope
   24 |       int x=p.first, y=p.second;
      |             ^
a.cc:25:18: error: 'y' was not declared in this scope
   25 |       if(used[x][y]) continue;
      |                  ^
a.cc:26:15: error: 'y' was not declared in this scope
   26 |       used[x][y]=1;
      |               ^
a.cc:30:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
   30 |           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:35:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
   35 |           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:40:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
   40 |           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:45:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
   45 |           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:49:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   49 |     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:49:16: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   49 |     cout<<ans<<endl;
      |                ^~~~
      |                std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~