criyle/codenet-compile-errors huggingface dataset:
Language: C

#include <stdio.h>
#include <queue>

using namespace std;

const int INF = 100000;
char maze[1005][1005];
int d[1005][1005];
int w, h;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

struct Coor {
	int x, y;
	Coor(int x, int y) : x(x), y(y) {}
};

queue<Coor> Q;

int bfs(int sx, int sy, int gx, int gy)
{
	int i, j;
	int nx, ny;
	
	while (Q.size() != 0){
		Q.pop();
	}
	
	for (i = 0; i < h; i++){
		for (j = 0; j < w; j++){
			d[i][j] = INF;
		}
	}
	
	d[sy][sx] = 0;
	
	Q.push(Coor(sx, sy));
	
	while (Q.size() != 0){
		
		Coor p = Q.front();
		Q.pop();
		
		if (p.x == gx && p.y == gy){
			break;
		}
		
		for (i = 0; i < 4; i++){
			
			nx = p.x + dx[i];
			ny = p.y + dy[i];
			
			if (nx >= 0 && ny >= 0 && nx < w && ny < h && maze[ny][nx] != 'X' && d[ny][nx] == INF){
				
				Q.push(Coor(nx, ny));
				d[ny][nx] = d[p.y][p.x] + 1;
			}
		}
	}
	return (d[gy][gx]);
}
			

int main(void)
{
	int n, ans = 0;
	int sx, sy;
	int x, y;
	int i, j;
	int gx[9], gy[9];
	
	scanf("%d %d %d", &h, &w, &n);
	
	for (i = 0; i < h; i++){
		for (j = 0; j < w; j++){
			scanf(" %c", &maze[i][j]);
			
			if (maze[i][j] == 'S'){
				sx = j;
				sy = i;
			}
			else if (maze[i][j] == '1'){
				gx[0] = j;
				gy[0] = i;
			}
			else if (maze[i][j] == '2'){
				gx[1] = j;
				gy[1] = i;
			}
			else if (maze[i][j] == '3'){
				gx[2] = j;
				gy[2] = i;
			}
			else if (maze[i][j] == '4'){
				gx[3] = j;
				gy[3] = i;
			}
			else if (maze[i][j] == '5'){
				gx[4] = j;
				gy[4] = i;
			}
			else if (maze[i][j] == '6'){
				gx[5] = j;
				gy[5] = i;
			}
			else if (maze[i][j] == '7'){
				gx[6] = j;
				gy[6] = i;
			}
			else if (maze[i][j] == '8'){
				gx[7] = j;
				gy[7] = i;
			}
			else if (maze[i][j] == '9'){
				gx[8] = j;
				gy[8] = i;
			}
		}
	}
	
	ans += bfs(sx, sy, gx[0], gy[0]);
	
	for (i = 1; i < n; i++){
		ans += bfs(gx[i - 1], gy[i -  1], gx[i], gy[i]);
	}
	
	printf("%d\n", ans);
	
	return (0);
}

Compiler output:
main.c:2:10: fatal error: queue: No such file or directory
    2 | #include <queue>
      |          ^~~~~~~
compilation terminated.
Language: C++

#include <cstdio>
#include <algorithm>
#include <queue>

using namespace std;

typedef pair<int, int> P;

const int MAX_H = 1000;
const int MAX_W = 1000;
const int MAX_N = 9;
const int INF = INT32_MAX;

char maze[MAX_H][MAX_W + 1];

int H, W, N;
int si, sj;
int gi[MAX_N + 1], gj[MAX_N + 1];
int d[MAX_H][MAX_W];

int dx[4] = {0,  1, 0, -1};
int dy[4] = {-1, 0, 1, 0};

int bfs(int goalNum)
{
  queue<P> que;
  int cgi = gi[goalNum], cgj = gj[goalNum];

  for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++)
      d[i][j] = INF;

  que.push(P(si, sj));
  d[si][sj] = 0;

  while (que.size()) {
    P p = que.front(); que.pop();

    if (p.first == cgi && p.second == cgj) break;

    for (int i = 0; i < 4; i++) {
      int ni = p.first + dx[i], nj = p.second + dy[i];

      if (0 <= ni && ni < H && 0 <= nj && nj < W && maze[ni][nj] != 'X' && d[ni][nj] == INF) {
        que.push(P(ni, nj));
        d[ni][nj] = d[p.first][p.second] + 1;
      }
    }
  }

  return d[cgi][cgj];
}

int solve()
{
  int res = 0;
  for (int i = 1; i <= N; i++) {
    // printf("%d:(%d, %d) => ", i, si, sj);
    res += bfs(i);
    si = gi[i]; sj = gj[i];
    // printf("(%d, %d):%d\n", si, sj, res);
  }
  return res;
}

int main()
{
  scanf("%d %d %d", &H, &W, &N);
  for (int i = 0; i < H; i++) {
    scanf("%s", maze[i]);
    maze[i][W] = 0;

    for (int j = 0; j < W; j++) {
      if ('0' < maze[i][j] && maze[i][j] <= '9') {
        gi[maze[i][j] - '0'] = i;
        gj[maze[i][j] - '0'] = j;
      }
      if (maze[i][j] == 'S') {
        si = i;
        sj = j;
      }
    }
  }

  printf("%d\n", solve());
}



Compiler output:
a.cc:12:17: error: 'INT32_MAX' was not declared in this scope
   12 | const int INF = INT32_MAX;
      |                 ^~~~~~~~~
a.cc:4:1: note: 'INT32_MAX' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
    3 | #include <queue>
  +++ |+#include <cstdint>
    4 |
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<string>
#include<cstdio>
#include<stack>
#include<cmath>
#include<bitset>
#include<memory>
#include<utility>
#include<map>
using namespace std;
#define FOR(i,m,n) for(i=m;i<n;i++)
#define CLR(a,b) memset(a,b,sizeof(a))
#define ROF(i,m,n) for(i=m;i>=n;i--)
#define BUG cout<<"debug"<<endl;
#define RT return
#define BK break
#define HEAP priority_queue
#define SP " "
#define rd(x) (rand()%(x))
#define lowf(a,b,c) lower_bound(a,b,c)
#define upf(a,b,c) upper_bound(a,b,c)
#define sh(a) cout<<a<<endl
typedef long long LL;
typedef vector<int> VI;
const int INF = 2147483647;
const int NEN = -INF - 1;
const LL LINF = 9223372036854775807;
int W, H, I1, J1,N;char g[1005][1005];
bool vis[1005][1005];
bool can(int x, int y)
{
	return x >= 0 && y >= 0 && x < H&&y < W&&g[x][y]!='X';
}
typedef struct node
{
	int i, j, sum;
	node()
	{
		;
	}
	node(int a, int b, int c)
	{
		i = a; j = b; sum = c;
	}
}node;
queue<node>bfs;
typedef struct pos
{
	int x,y;
}pos;
pos all[10];
int dir[4][2] = { {1,0},{-1,0},{0,1},{0,-1} };
int main()
{
	cin >> H >> W >> N;
	node temp;
	int T,i,j,ans=0;
	FOR(i, 0, H)
	{
		FOR(j, 0, W)
		{
			//cin >> g[i][j];
                  scanf("%c",&g[i][j]);
			if (g[i][j] > '0'&&g[i][j] <='9')
			{
				all[g[i][j] - 48].x = i;
				all[g[i][j] - 48].y = j;
			}
			else if (g[i][j] == 'S')I1 = i, J1 = j;
		}
	}
	FOR(T,0,N)
	{
		CLR(vis, 0);
		while (!bfs.empty())bfs.pop();
		if(T>0)bfs.push(node(all[T].x, all[T].y, 0));
		else bfs.push(node(I1, J1, 0));
		while (!bfs.empty())
		{
			temp = bfs.front();
			bfs.pop();
			if (g[temp.i][temp.j] == T+48+1)
			{
				ans += temp.sum;
				break;
			}
			int k = 4,tx,ty;
			while (k--)
			{
				tx = temp.i + dir[k][0];
				ty = temp.j + dir[k][1];
				if (can(tx, ty) == true&&!vis[tx][ty])
				{
					vis[tx][ty] = 1;
					bfs.push(node(tx, ty, temp.sum + 1));
				}
			}
		}
	}
	cout << ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:18: error: 'memset' was not declared in this scope
   16 | #define CLR(a,b) memset(a,b,sizeof(a))
      |                  ^~~~~~
a.cc:78:17: note: in expansion of macro 'CLR'
   78 |                 CLR(vis, 0);
      |                 ^~~
a.cc:14:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   13 | #include<map>
  +++ |+#include <cstring>
   14 | using namespace std;
Language: C++

#include <iostream>
#include <utility>
#include <queue>
using namespace std;

typedef pair<int, int> Pair;
const int INF = 100000000;

int H, W;
char N;
const int MAX_H = 1000, MAX_W = 1000;
char plant[MAX_H][MAX_W];
int sx, sy;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
int d[MAX_H][MAX_W];
int time;

void bfs() {
    queue<Pair> que;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            d[i][j] = INF;
        }
    }
    char muscle = '1';
    que.push(Pair(sx,sy));
    d[sx][sy] = 0;
    while (que.size()) {
        Pair p  = que.front(); que.pop();
        if (muscle-1 == N) break;
        for (int i = 0; i < 4; i++) {
            int nx = p.first + dx[i], ny = p.second + dy[i];
            if (0 <= nx && nx < H && 0 <= ny && ny < W && plant[nx][ny] != 'X' && d[nx][ny] == INF) {
                que.push(Pair(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
            if (muscle == plant[nx][ny]) {
                while(que.size()) {que.pop();}
                que.push(Pair(nx, ny));
                muscle = muscle + 1;
                time += d[nx][ny];
                for (int i = 0; i < H; i++) {
                    for (int j = 0; j < W; j++) {
                        d[i][j] = INF;
                    }
                }
                d[nx][ny] = 0;
                break;
            }
        }
    }
}

void solve() {
    time = 0;
    bfs();
    cout << time << endl;
}

int main () {
    cin >> H >> W >> N;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> plant[i][j];
            if(plant[i][j] == 'S') {sx = i; sy = j;}
        }
    }
    solve();
}




Compiler output:
a.cc:16:5: error: 'int time' redeclared as different kind of entity
   16 | int time;
      |     ^~~~
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'void bfs()':
a.cc:41:22: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   41 |                 time += d[nx][ny];
      |                 ~~~~~^~~~~~~~~~~~
a.cc:41:22: error: assignment of read-only location 'time'
a.cc: In function 'void solve()':
a.cc:55:10: error: assignment of function 'time_t time(time_t*)'
   55 |     time = 0;
      |     ~~~~~^~~
Language: C++

#include <iostream>
#include <utility>
#include <queue>
using namespace std;

typedef pair<int, int> Pair;
const int INF = 100000000;

int H, W;
char N;
const int MAX_H = 1000, MAX_W = 1000;
char plant[MAX_H][MAX_W];
int sx, sy;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
int d[MAX_H][MAX_W];
int time;

void bfs() {
    queue<Pair> que;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            d[i][j] = INF;
        }
    }
    char muscle = '1';
    que.push(Pair(sx,sy));
    d[sx][sy] = 0;
    while (que.size()) {
        Pair p  = que.front(); que.pop();
        if (muscle-1 == N) break;
        for (int i = 0; i < 4; i++) {
            int nx = p.first + dx[i], ny = p.second + dy[i];
 if (0 <= nx && nx < H && 0 <= ny && ny < W && plant[nx][ny] != 'X' && d[nx][ny] == INF) {
                que.push(Pair(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
            if (muscle == plant[nx][ny]) {
                while(que.size()) {que.pop();}
                que.push(Pair(nx, ny));
                muscle = muscle + 1;
                time += d[nx][ny];
                for (int i = 0; i < H; i++) {
                    for (int j = 0; j < W; j++) {
                        d[i][j] = INF;
                    }
                }
                d[nx][ny] = 0;
                break;
            }
        }
    }
}

void solve() {
    time = 0;
    bfs();
    cout << time << endl;
}

int main () {
    cin >> H >> W >> N;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> plant[i][j];
            if(plant[i][j] == 'S') {sx = i; sy = j;}
        }
    }
    solve();
}




Compiler output:
a.cc:16:5: error: 'int time' redeclared as different kind of entity
   16 | int time;
      |     ^~~~
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'void bfs()':
a.cc:41:22: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   41 |                 time += d[nx][ny];
      |                 ~~~~~^~~~~~~~~~~~
a.cc:41:22: error: assignment of read-only location 'time'
a.cc: In function 'void solve()':
a.cc:55:10: error: assignment of function 'time_t time(time_t*)'
   55 |     time = 0;
      |     ~~~~~^~~
Language: C++

#include <iostream>
#include <utility>
#include <queue>
using namespace std;

typedef pair<int, int> Pair;
const int INF = 100000000;

int H, W;
char N;
const int MAX_H = 1000, MAX_W = 1000;
char plant[MAX_H][MAX_W];
int sx, sy;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
int d[MAX_H][MAX_W];
int time;

void bfs() {
    queue<Pair> que;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            d[i][j] = INF;
        }
    }
    char muscle = '1';
    que.push(Pair(sx,sy));
    d[sx][sy] = 0;
    while (que.size()) {
        Pair p  = que.front(); que.pop();
        if (muscle-1 == N) break;
        for (int i = 0; i < 4; i++) {
            int nx = p.first + dx[i], ny = p.second + dy[i];
            if (0 <= nx && nx < H && 0 <= ny && ny < W && plant[nx][ny] != 'X' && d[nx][ny] == INF) {
                que.push(Pair(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
            if (muscle == plant[nx][ny]) {
                while(que.size()) {que.pop();}
                que.push(Pair(nx, ny));
                muscle = muscle + 1;
                time += d[nx][ny];
                for (int i = 0; i < H; i++) {
                    for (int j = 0; j < W; j++) {
                        d[i][j] = INF;
                    }
                }
                d[nx][ny] = 0;
                break;
            }
        }
    }
}

void solve() {
    time = 0;
    bfs();
    cout << time << endl;
}

int main () {
    cin >> H >> W >> N;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> plant[i][j];
            if(plant[i][j] == 'S') {sx = i; sy = j;}
        }
    }
    solve();
    return 0;
}


Compiler output:
a.cc:16:5: error: 'int time' redeclared as different kind of entity
   16 | int time;
      |     ^~~~
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'void bfs()':
a.cc:41:22: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   41 |                 time += d[nx][ny];
      |                 ~~~~~^~~~~~~~~~~~
a.cc:41:22: error: assignment of read-only location 'time'
a.cc: In function 'void solve()':
a.cc:55:10: error: assignment of function 'time_t time(time_t*)'
   55 |     time = 0;
      |     ~~~~~^~~
Language: C++


#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <queue>
using namespace std;

int h,w,n;
char map[1010][1010]={0};
bool flag[1010][1010]={false};
int arr[11][2]={0};
int dir[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

class node
{
public: 
	node(int x,int y,int s);
	int x;
	int y;
	int s;
};
node::node(int x,int y,int s)
{
	this->x=x;
	this->y=y;
	this->s=s;
}

int bfs(int sx,int sy,int dx,int dy)
{
	queue<node> que;
	node no(sx,sy,0);
	que.push(no);
	flag[sx][sy]=true;
	while(!que.empty())
	{
		node cur=que.front();
		que.pop();
		if(cur.x==dx && cur.y==dy)
			return cur.s;
		for(int i=0;i<4;i++)
		{
			int tx=cur.x+dir[i][0];
			int ty=cur.y+dir[i][1];
			if(map[tx][ty]!='X' && flag[tx][ty] !=true && tx>=0 && tx<h && ty>=0 && ty<w)
			{
				node next(tx,ty,cur.s+1);
				que.push(next);
				flag[tx][ty]=true;
			}
		}
	}
	return -1;
}

int main()
{
	cin>>h>>w>>n;
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
		{
			cin>>map[i][j];
			if(map[i][j]=='S')
			{
				arr[0][0]=i;
				arr[0][1]=j;
				map[i][j]='.';
			}
			else if(isdigit(map[i][j]))
			{
				int d=map[i][j]-'0';
				arr[d][0]=i;
				arr[d][1]=j;
			}
		}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		memset(flag,false,sizeof(flag));
		ans+=bfs(arr[i][0],arr[i][1],arr[i+1][0],arr[i+1][1]);
	}
	cout<<ans<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:79:17: error: 'memset' was not declared in this scope
   79 |                 memset(flag,false,sizeof(flag));
      |                 ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include <queue>
  +++ |+#include <cstring>
    6 | using namespace std;
Language: C++

#include <iostream>
#include <queue>
using namespace std;
#define MAXN 1001
char A[MAXN][MAXN];
int w,h,n;
int s[2];

void input()
{
    cin>>h>>w>>n;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>A[i][j];
            if(A[i][j]=='S'){
                s[0]=i;
                s[1]=j;
            }
        }
    }
}

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
using P = pair<pair<int,int>,int>;

int known[MAXN][MAXN];

int bfs(int& x, int& y, char k)
{
    queue<P>que;
    que.push(P(make_pair(x, y), 0));
    while(!que.empty()){
        P cur = que.front();
        // cout<<"*"<<cur.first.first<<" "<<cur.first.second<<endl;
        que.pop();
        if(A[cur.first.first][cur.first.second]==k){
            x = cur.first.first;
            y = cur.first.second;
            return cur.second;
        }
        for(int i=0;i<4;i++){
            int nx = cur.first.first+dx[i];
            int ny = cur.first.second+dy[i];
            if(0<=nx&&nx<h && 0<=ny&&ny<w && A[nx][ny]!='X' && !known[nx][ny]){
                que.push(P(make_pair(nx, ny), cur.second+1));
                known[nx][ny]=1;
            }
        }
    }
    return 0x3fffffff;
}

int main()
{
    input();
    int res = 0;
    int x, y;
    x = s[0];
    y = s[1];

    for(int i=1;i<=n;i++){
        memset(known, 0, sizeof(int)*MAXN*MAXN);
        int tmp = bfs(x, y, '0'+i);
        res += tmp;
    }
    cout<<res<<endl;
    return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:63:9: error: 'memset' was not declared in this scope
   63 |         memset(known, 0, sizeof(int)*MAXN*MAXN);
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <queue>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

#include <iostream>
#include <queue>
using namespace std;
#define MAXN 1001
char A[MAXN][MAXN];
int w,h,n;
int s[2];

void input()
{
    cin>>h>>w>>n;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>A[i][j];
            if(A[i][j]=='S'){
                s[0]=i;
                s[1]=j;
            }
        }
    }
}

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
typedef pair<pair<int,int>,int> P;

int known[MAXN][MAXN];

int bfs(int& x, int& y, char k)
{
    queue<P>que;
    que.push(P(make_pair(x, y), 0));
    while(!que.empty()){
        P cur = que.front();
        // cout<<"*"<<cur.first.first<<" "<<cur.first.second<<endl;
        que.pop();
        if(A[cur.first.first][cur.first.second]==k){
            x = cur.first.first;
            y = cur.first.second;
            return cur.second;
        }
        for(int i=0;i<4;i++){
            int nx = cur.first.first+dx[i];
            int ny = cur.first.second+dy[i];
            if(0<=nx&&nx<h && 0<=ny&&ny<w && A[nx][ny]!='X' && !known[nx][ny]){
                que.push(P(make_pair(nx, ny), cur.second+1));
                known[nx][ny]=1;
            }
        }
    }
    return 0x3fffffff;
}

int main()
{
    input();
    int res = 0;
    int x, y;
    x = s[0];
    y = s[1];

    for(int i=1;i<=n;i++){
        memset(known, 0, sizeof(int)*MAXN*MAXN);
        int tmp = bfs(x, y, '0'+i);
        res += tmp;
    }
    cout<<res<<endl;
    return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:63:9: error: 'memset' was not declared in this scope
   63 |         memset(known, 0, sizeof(int)*MAXN*MAXN);
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <queue>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

#include <iostream>
#include <queue>
#include <string>
using namespace std;
#define MAXN 1001
char A[MAXN][MAXN];
int w,h,n;
int s[2];

void input()
{
    cin>>h>>w>>n;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>A[i][j];
            if(A[i][j]=='S'){
                s[0]=i;
                s[1]=j;
            }
        }
    }
}

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
typedef pair<pair<int,int>,int> P;

int known[MAXN][MAXN];

int bfs(int& x, int& y, char k)
{
    queue<P>que;
    que.push(P(make_pair(x, y), 0));
    while(!que.empty()){
        P cur = que.front();
        // cout<<"*"<<cur.first.first<<" "<<cur.first.second<<endl;
        que.pop();
        if(A[cur.first.first][cur.first.second]==k){
            x = cur.first.first;
            y = cur.first.second;
            return cur.second;
        }
        for(int i=0;i<4;i++){
            int nx = cur.first.first+dx[i];
            int ny = cur.first.second+dy[i];
            if(0<=nx&&nx<h && 0<=ny&&ny<w && A[nx][ny]!='X' && !known[nx][ny]){
                que.push(P(make_pair(nx, ny), cur.second+1));
                known[nx][ny]=1;
            }
        }
    }
    return 0x3fffffff;
}

int main()
{
    input();
    int res = 0;
    int x, y;
    x = s[0];
    y = s[1];

    for(int i=1;i<=n;i++){
        memset(known, 0, sizeof(int)*MAXN*MAXN);
        int tmp = bfs(x, y, '0'+i);
        res += tmp;
    }
    cout<<res<<endl;
    return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:64:9: error: 'memset' was not declared in this scope
   64 |         memset(known, 0, sizeof(int)*MAXN*MAXN);
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <queue>
  +++ |+#include <cstring>
    3 | #include <string>
Language: C++

//幅優先探索
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<set>
#include<map>
#include<memory>
#define FOR(i,R) for(int i=0;i<R;i++)
#define ZERO(a) memset(a,0,sizeof(a))
using namespace std;
typedef pair<int,int> P;

const int INF=10000;
//init()
char maze[1024][1024];
int H,W,N;
int sx,sy;
int gx,gy;

int e[16][3];
int d[1024][1024];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int bfs(){
	queue<P> que;
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)d[i][j]=INF;
	que.push(P(sx,sy));
	d[sx][sy]=0;
	
	while(que.size()){
		P p=que.front(); que.pop();
		if(p.first==gx&&p.second==gy)break;
		for(int i=0;i<4;i++){
			int nx=p.first+dx[i],ny=p.second+dy[i];
			if(0<=nx&&nx<H&&0<=ny&&ny<W&&maze[nx][ny]!='X'&&d[nx][ny]==INF){
				que.push(P(nx,ny));
				d[nx][ny]=d[p.first][p.second]+1;
			}
		}
	}
	return d[gx][gy];
}

void main(){
	int i,j,k=0,t=0;
	cin>>H>>W>>N;
	FOR(i,H)FOR(j,W){
		cin>>maze[i][j];
		if(maze[i][j]=='S'){
			sx=i;sy=j;
		}else if('0'<=maze[i][j]&&maze[i][j]<='9'){
			k=maze[i][j]-'0';
			e[k][0]=i;e[k][1]=j;
		}
	}
	
	FOR(i,N){
		if(i==0){
			gx=e[1][0];
			gy=e[1][1];
		}else{
			sx=e[i][0];
			sy=e[i][1];
			gx=e[i+1][0];
			gy=e[i+1][1];
		}
		t+=bfs();
	}
	cout<<t<<endl;
}

Compiler output:
a.cc:47:1: error: '::main' must return 'int'
   47 | void main(){
      | ^~~~
Language: C++

#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <array>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>

#pragma warning(disable:4996)
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
typedef long long Int;

using namespace std;

struct point{
	Int j, i,step;
	point(Int i_, Int j_,Int s) :i(i_), j(j_),step(s){}
};

int dx[4] = { 0, -1, 0, 1 };
int dy[4] = { 1, 0, -1, 0 };

queue<point> que;
char tile[1001][1001];
int H, W;
bool ed[1001][1001];

point solve(char target)
{
	while (!que.empty()){
		point now(que.front());
		ed[now.i][now.j] = true;
		que.pop();
		REP(i, 4){
			int x = now.j + dx[i];
			int y = now.i + dy[i];

			if (x < 0 || y < 0 || x > W || y > H || ed[y][x])
				continue;

			if (tile[y][x] == target){
				return point(y, x,now.step+1);
			}

			if (tile[y][x] != 'X'){
				que.push(point(y, x, now.step + 1));
				ed[y][x] = true;
			}
		}
	}
}

int main()
{
	cin.tie(0); ios::sync_with_stdio(false);
	//fstream fs("input.txt");
	////////////ここから開始///////////
	int n(0);
	cin >> H >> W >> n;

	REP(i, 1001)REP(j, 1001){ tile[i][j] = 'X'; ed[i][j] = false; }

	REP(i, H)REP(j, W)cin >> tile[i][j];

	REP(i, H)REP(j, W){ if (tile[i][j] == 'S')que.emplace(i, j, 0); }

	for (int i = 0; i < n; ++i){
		REP(i_1, H + 1)REP(j_1, W + 1){ ed[i_1][j_1] = false; }
		point t = solve('1' + i);
		que = {};
		que.emplace(t);
		que.front().step
	}

	cout << que.front().step << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:76:33: error: expected ';' before '}' token
   76 |                 que.front().step
      |                                 ^
      |                                 ;
   77 |         }
      |         ~                        
a.cc: In function 'point solve(char)':
a.cc:55:1: warning: control reaches end of non-void function [-Wreturn-type]
   55 | }
      | ^
Language: C++

#include <stdio.h>

int main() {
    int i, j;
    int h, w, n;

    scanf("%d %d %d", &h, &w, &n);
    for (i=0; i<h; i++) {
        for (j=0; j<w; j++) {
            int c;

            scanf(" %c", &c);
            if (c == 'S')
             

Compiler output:
a.cc: In function 'int main()':
a.cc:13:26: error: expected statement at end of input
   13 |             if (c == 'S')
      |                          ^
a.cc:13:26: error: expected '}' at end of input
a.cc:9:29: note: to match this '{'
    9 |         for (j=0; j<w; j++) {
      |                             ^
a.cc:13:26: error: expected '}' at end of input
   13 |             if (c == 'S')
      |                          ^
a.cc:8:25: note: to match this '{'
    8 |     for (i=0; i<h; i++) {
      |                         ^
a.cc:13:26: error: expected '}' at end of input
   13 |             if (c == 'S')
      |                          ^
a.cc:3:12: note: to match this '{'
    3 | int main() {
      |            ^
Language: C++

#include<iostream>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> P;
queue<P> q;
int sx,sy;
int gx,gy;
int g;
char field[1000][1000];
int d[1000][1000];
int H,W,N;
int hp=1;
int ans=0;

int bfs(){
	memset(d,-1,sizeof(d));
	P p;
	q.push(P(sx,sy));
	d[sx][sy]=0;
	while(q.size()){
		if(q.front().first==gx&&q.front().second==gy) break;
		p=q.front();
		q.pop();
		for(int i=-1;i<=1;i++){
			for(int j=-1;j<=1;j++){
				if((i==0||j==0)&&(i!=0||j!=0)){
					if(p.first+i>=0&&p.first+i<=H-1&&p.second+j>=0&&p.second+j<=W-1&&d[p.first+i][p.second+j]<0){
						if(field[p.first+i][p.second+j]!='X'){
							q.push(P(p.first+i,p.second+j));
							d[p.first+i][p.second+j]=d[p.first][p.second]+1;
						}
					}
				}
			}
		}
		
	}
	return d[gx][gy];
}
int main(){
	cin>>H>>W>>N;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin>>field[i][j];
		}
	}
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(field[i][j]=='S')
			{
				sx=i;
				sy=j;
			}
			if(field[i][j]==49)
			{
				gx=i;
				gy=j;
			}
		}
	}
	ans+=bfs();
	for(int i=0;i<N-1;i++){
		for(int j=0;j<H;j++){
			for(int k=0;k<W;k++){
				if(field[j][k]==49+i)
				{
					sx=j;
					sy=k;
				}
				if(field[j][k]==50+i)
				{
					gx=j;
					gy=k;
				}
			}
		}
		while(q.size()){
			q.pop();
		}
		memset(d,-1,sizeof(d));
		ans+=bfs();
	}

	cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int bfs()':
a.cc:19:9: error: 'memset' was not declared in this scope
   19 |         memset(d,-1,sizeof(d));
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include<queue>
  +++ |+#include <cstring>
    4 | 
a.cc: In function 'int main()':
a.cc:83:17: error: 'memset' was not declared in this scope
   83 |                 memset(d,-1,sizeof(d));
      |                 ^~~~~~
a.cc:83:17: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

#include<iostream>
#include<queue>
using namespace std;
struct ma
{
	int x;
	int y;
};
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
int main()
{
	int ans = 0;
	int tate, yoko;
	int n;
	cin >> tate >> yoko >> n;
	char m[1100][1100];
	ma sta;
	for (int i = 0; i < tate; i++)
	{
		for (int k = 0; k < yoko; k++)
		{
			cin >> m[i][k];
			if (m[i][k] == 'S')
			{
				sta.x = k;
				sta.y = i;
			}
		}
	}
	int HP = 1;
	queue<ma> hoge;
	for (int i = 0; i < n; i++)
	{
		hoge.push(sta);
		int map[1100][1100];
		memset(map, -1, sizeof(map));
		map[sta.y][sta.x] = 0;
		while (!hoge.empty())
		{
			ma now;
			now = hoge.front();
			hoge.pop();
			for (int k = 0; k < 4; k++)
			{
				if (now.y + dy[k] < 0 || now.x + dx[k] < 0)continue;
				if (m[now.y + dy[k]][now.x + dx[k]] != 'X')
				{
					if (map[now.y + dy[k]][now.x + dx[k]] != -1)
					{
						continue;
					}
					map[now.y + dy[k]][now.x + dx[k]] = map[now.y][now.x] + 1;
					if (m[now.y + dy[k]][now.x + dx[k]] - '0' == HP)
					{
						m[now.y + dy[k]][now.x + dx[k]] = '.';
						ans += map[now.y + dy[k]][now.x + dx[k]];
						while (!hoge.empty())hoge.pop();
						HP++;
						sta.x = now.x + dx[k];
						sta.y = now.y + dy[k];
						break;
					}
					else
					{
						ma hage;
						hage.x = now.x + dx[k];
						hage.y = now.y + dy[k];
						hoge.push(hage);
					}
				}
			}

		/*	for (int i = 0; i < tate; i++)
			{
				for (int k = 0; k < yoko; k++)
				{
					cout << map[i][k] << " ";
				}
				cout << endl;
			}
			cout << endl;*/
		}
	}
	cout << ans << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:17: error: 'memset' was not declared in this scope
   36 |                 memset(map, -1, sizeof(map));
      |                 ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include<queue>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int n,m,l,cnt,mx,my;
char a[1019][1019];
int vis[1019][1019];
pair<int,int> p[10],st;
int mov[4][2] = {1,0,0,-1,-1,0,0,1};
struct status
{
    int x,y;
    int ord;
    int fx;
    status(int a,int b,int c,int s)
    {
        x = a, y = b, ord = c, fx = s;
    }
    bool operator < (struct status t) const
    {
        if(ord != t.ord) return ord > t.ord;
        else return fx > t.fx;
    }
}tt[4];

void bfs(int x,int y,int color)
{
    queue <struct status> q;
    struct status temp(x,y,0,fabs(x-p[color].first) + fabs(y - p[color].second));
    q.push(temp);
    int flag = 0;
    while(!q.empty())
    {
        struct status nw = q.top();
        q.pop();
        if(nw.x == p[color].first && nw.y == p[color].second)
        {
            cnt += nw.ord;
            break;
        }
        vis[nw.x][nw.y] = 1;
        for(int i=0;i<4;i++)
        {
            int tx = mov[i][0] + nw.x, ty = nw.y + mov[i][1];
            if(tx>=0 && tx< n && ty>=0 && ty< m && !vis[tx][ty] && a[tx][ty] != 'X')
            {
                struct status tmp(tx,ty,nw.ord+1,fabs(tx-p[color].first) + fabs(ty - p[color].second));
                tt[i] = tmp;
                vis[tx][ty] = 1;
            }
        }
        sort(tt,tt+4);
        for(int i=0;i<4;i++) q.push(tt[i]);
    }
}

int main()
{
    while(~scanf("%d%d%d",&n,&m,&l))
    {
        getchar();
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                scanf("%c",&a[i][j]);
                if(a[i][j]>='0' && a[i][j]<='9')
                    p[a[i][j]-'0'].first = i, p[a[i][j]-'0'].second = j;
                if(a[i][j] == 'S') st.first = i, st.second = j;
            }
            getchar();
        }

        int sx = st.first, sy = st.second;
        cnt = 0;
        for(int i=1;i<=l;i++)
        {
            memset(vis,0,sizeof(vis));
            bfs(sx,sy,i);
            sx = p[i].first, sy = p[i].second;
        }
        printf("%d\n",cnt);
    }
    return 0;
}

Compiler output:
a.cc:28:6: error: no matching function for call to 'status::status()'
   28 | }tt[4];
      |      ^
a.cc:19:5: note: candidate: 'status::status(int, int, int, int)'
   19 |     status(int a,int b,int c,int s)
      |     ^~~~~~
a.cc:19:5: note:   candidate expects 4 arguments, 0 provided
a.cc:14:8: note: candidate: 'constexpr status::status(const status&)'
   14 | struct status
      |        ^~~~~~
a.cc:14:8: note:   candidate expects 1 argument, 0 provided
a.cc:14:8: note: candidate: 'constexpr status::status(status&&)'
a.cc:14:8: note:   candidate expects 1 argument, 0 provided
a.cc: In function 'void bfs(int, int, int)':
a.cc:38:30: error: 'class std::queue<status>' has no member named 'top'; did you mean 'pop'?
   38 |         struct status nw = q.top();
      |                              ^~~
      |                              pop
Language: C++

#include <stdio.h>
#include <queue>
using namespace std;
int d[1000][1000], sx, sy;
char s[1000][1000];
int h,w,n;
int k, l;

int bfs(int,int,int,int);

int main(){
  int result = 0;
  int x[10], y[10], v;
  scanf("%d %d %d", &h, &w, &n);
  for(k = 0 ; k < h ; k++){
      scanf("%s",s[k]);javascript:void(0)
    }
  for( k = 0 ; k < h ; k++ ){
    for( l = 0 ; l < w ; l++){
      if(s[k][l] == 'S'){
	x[0] = l; y[0] = k;
      }
      if('1' <= s[k][l] && s[k][l] <= '9'){
	v = s[k][l]-'1'+1;
	x[v] = l; y[v] = k;
      }
    }
  }
  for (k = 1 ; k <= n ; k++){
   
    result += bfs(x[k-1],y[k-1],x[k],y[k]);
  }
  printf("%d\n", result);
  return 0;
}

int bfs(int sx, int sy, int gx, int gy){
  queue<int> Q;
  int i, j;
  int dx[4]={0, 1, 0, -1};
  int dy[4]={1, 0, -1, 0};
  

  for( i =  0 ; i < h ; i++ ){
    for( j = 0 ; j < w ; j++ ){
      d[i][j] = 100000;
    }
  }

  Q.push(sy*w+sx);
  d[sy][sx]=0; /*スタート地点の初期化*/

  while( !Q.empty() ){
    int u = Q.front(); Q.pop();
    int pi = u/w;
    int pj = u%w;
    if( pi == gy && pj == gx )return d[gy][gx];
    for ( int r = 0; r < 4; r++ ){
      int ni = pi + dy[r];
      int nj = pj + dx[r];
      if ( ni < 0 || nj < 0 || ni >= h || nj >= w ) continue;
      if ( s[ni][nj] == 'X' ) continue;
      if( d[ni][nj] > d[pi][pj]+1 ){
      d[ni][nj] = d[pi][pj] + 1;
      Q.push( ni * w + nj );
      }

    }


  }
  //  printf("%d\n",u);
  return -1;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:42: error: expected ';' before '}' token
   16 |       scanf("%s",s[k]);javascript:void(0)
      |                                          ^
      |                                          ;
   17 |     }
      |     ~
Language: C++

#include <iostream>
#include <cstdio>
#include <queue>

using namespace std;

int sx,sy;

typedef struct place
{
	int x;
	int y;
}P;

char map[1005][1005];
int d[1005][1005];
int dd[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
int ans;
int h,w,n;
int tempx,tempy;

void bfs(int i,int j,int n)
{
	queue<P> q;
	P p1={i,j};
	q.push(p1);
	d[i][j]=0;
	while(q.size())
	{
		P p=q.front();
		q.pop();
		if(map[p.x][p.y]==n+48)
		{
			tempx=p.x;
			tempy=p.y;
			ans+=d[p.x][p.y];
			break;
		}
		for(int i=0;i<4;i++)
		{
			int nx=p.x+dd[i][0];
			int ny=p.y+dd[i][1];
			if(map[nx][ny]!='X' && nx>=0 && ny>=0 && nx<=h && ny<=w && d[nx][ny]==-1)
			{
				d[nx][ny]=d[p.x][p.y]+1;
				P p1={nx,ny};
				q.push(p1);
			}
		}
	}
}

int main()
{
	while(scanf("%d %d %d",&h,&w,&n)!=EOF)
	{
		ans=0;
		for(int i=0;i<h;i++)
		{
			for(int j=0;j<w;j++)
			{
				cin>>map[i][j];
				d[i][j]=-1;
				if(map[i][j]=='S')
				{
					sx=i;
					sy=j;
				}
			}
		}
		tempx=sx;
		tempy=sy;
		for(int l=1;l<=n;l++)
		{
			memset(d,-1,sizeof(d));
			bfs(tempx,tempy,l);
		}
		cout<<ans<<endl;
	}
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:75:25: error: 'memset' was not declared in this scope
   75 |                         memset(d,-1,sizeof(d));
      |                         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <queue>
  +++ |+#include <cstring>
    4 |
Language: C++

#include <iostream>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
 
 
 
int main()
{
 
    queue < pair<int, int> > q;
    pair<int, int> p;
 
 
 
    char **m;
    char c[10] = { "123456789" };
    int **f;
	bool flg = false;
    int n, k, i, i1, c1, i2, sum = 0;
    cin >> n;
    cin >> k;
    cin >> c1;
 
    m = new char *[n + 2];
    f = new int *[n + 2];
 
    for (i = 0; i < n + 2; i++){
        m[i] = new char[k + 2];
        f[i] = new int[k + 2];
    }
 
    for (i = 1; i <= n; i++){
        for (i1 = 1; i1 <= k; i1++){
            cin >> m[i][i1];
        }
    }
 
    for (i = 0; i < n + 2; i++){
        for (i1 = 0; i1 < k + 2; i1++){
            if (i == 0 || i == n + 1){
                m[i][i1] = 'X';
            }
            else if (i1 == 0 || i1 == k + 1){
                m[i][i1] = 'X';
            }
        }
    }
 
    for (i = 1; i <= n; i++){
        for (i1 = 1; m[i][i1] != '\0'; i1++){
            if (m[i][i1] == 'S'){
                q.push(make_pair(i, i1));
            }
        }
    }
 
 
 
    pair<int, int> temp;
 
    temp = q.front();
 
    for (i = 0; i < c1; i++){

		for (i1 = 0; i1 < n + 2; i1++){
				for (i2 = 0; i2 < k + 2; i2++){
					if ((i1 == 0 || i1 == n + 1) && !flg){
						f[i1][i2] = 1;
					}
					else if ((i2 == 0 || i2 == k + 1) && !flg){
						f[i1][i2] = 1;
					}
					else
						f[i1][i2] = -1;
				}
		}
		flg = true;
		}

        f[temp.first][temp.second] = 0;
 
		while (!q.empty()){
            p = q.front();
            q.pop();
 
            int x[4] = { -1, 1, 0, 0 }, y[4] = { 0, 0, -1, 1 };
 
            for (int j = 0; j < 4; j++){
 
                //???????????´??????????´¢
                if (m[p.first + x[j]][p.second + y[j]] != 'X' && f[p.first + x[j]][p.second + y[j]] < 0){
                    q.push(make_pair(p.first + x[j], p.second + y[j]));
                    f[p.first + x[j]][p.second + y[j]] = f[p.first][p.second] + 1;
                }
            }
            //??´?????????????????????
            if (m[p.first][p.second] == c[i]){
                sum += f[p.first][p.second];
                temp = p;
                while (!q.empty()){
                    q.pop();
                }
                q.push(p);
                break;
			}
		}
	}
 
    cout << sum << endl;
 
    return 0;
}

Compiler output:
a.cc:113:5: error: 'cout' does not name a type
  113 |     cout << sum << endl;
      |     ^~~~
a.cc:115:5: error: expected unqualified-id before 'return'
  115 |     return 0;
      |     ^~~~~~
a.cc:116:1: error: expected declaration before '}' token
  116 | }
      | ^
Language: C++

#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
int m,n,t;
int cnt;
char c;
char map[1010][1010];
bool vis[1010][1010];
struct node
{
	int x,y;
	int step;
}start;
int way[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
void bfs()
{
	queue <node> abc;
	abc.push(start);
	while(!abc.empty())
	{
		node k = abc.front(); 
		abc.pop();
		if(map[k.y][k.x] == c)
		{
			cnt+=k.step;
			k.step = 0;
			memset(vis,0,sizeof(vis));
			while(!abc.empty())
			abc.pop();
			c++;
			t--;
		}
		if(t==0)
		{
			return;
		}
		for(int i = 0;i<4;i++)
		{
			int dx = k.x+way[i][0];
			int dy = k.y+way[i][1];
			if(dx>=0 && dx<n && dy>=0 && dy<m && !vis[dy][dx] &&map[dy][dx]!='X')
			{
				node temp;
				temp.x = dx;
				temp.y = dy;
				temp.step = k.step+1;
				abc.push(temp);
				vis[dy][dx]=1;
			}
		}
	}	
} 
int main()
{
	while(cin >> m >> n >> t)
	{
		cnt = 0;
		c = '1';
		memset(vis,0,sizeof(vis));
		memset(map,0,sizeof(map));
		for(int i = 0;i<m;i++)
		{
			for(int j = 0;j<n;j++)
			{
				cin >> map[i][j];
				if(map[i][j] == 'S')
				{
					start.x = j;
					start.y = i;
					start.step = 0;
				}
			}
		}
		bfs();
		cout << cnt << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'void bfs()':
a.cc:28:25: error: 'memset' was not declared in this scope
   28 |                         memset(vis,0,sizeof(vis));
      |                         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <algorithm>
  +++ |+#include <cstring>
    4 | using namespace std;
a.cc: In function 'int main()':
a.cc:60:17: error: 'memset' was not declared in this scope
   60 |                 memset(vis,0,sizeof(vis));
      |                 ^~~~~~
a.cc:60:17: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

#include <memory>
#include <cstring>
#include <string>
#include <memory.h>
using namespace std;
int m,n,t;
int cnt;
char c;
char map[1010][1010];
bool vis[1010][1010];
struct node
{
	int x,y;
	int step;
}start;
int way[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
void bfs()
{
	queue <node> abc;
	abc.push(start);
	while(!abc.empty())
	{
		node k = abc.front(); 
		abc.pop();
		if(map[k.y][k.x] == c)
		{
			cnt+=k.step;
			k.step = 0;
			memset(vis,0,sizeof(vis));
			while(!abc.empty())
			abc.pop();
			c++;
			t--;
		}
		if(t==0)
		{
			return;
		}
		for(int i = 0;i<4;i++)
		{
			int dx = k.x+way[i][0];
			int dy = k.y+way[i][1];
			if(dx>=0 && dx<n && dy>=0 && dy<m && !vis[dy][dx] &&map[dy][dx]!='X')
			{
				node temp;
				temp.x = dx;
				temp.y = dy;
				temp.step = k.step+1;
				abc.push(temp);
				vis[dy][dx]=1;
			}
		}
	}	
} 
int main()
{
	while(cin >> m >> n >> t)
	{
		cnt = 0;
		c = '1';
		memset(vis,0,sizeof(vis));
		memset(map,0,sizeof(map));
		for(int i = 0;i<m;i++)
		{
			for(int j = 0;j<n;j++)
			{
				cin >> map[i][j];
				if(map[i][j] == 'S')
				{
					start.x = j;
					start.y = i;
					start.step = 0;
				}
			}
		}
		bfs();
		cout << cnt << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'void bfs()':
a.cc:19:9: error: 'queue' was not declared in this scope
   19 |         queue <node> abc;
      |         ^~~~~
a.cc:5:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
    4 | #include <memory.h>
  +++ |+#include <queue>
    5 | using namespace std;
a.cc:19:20: error: expected primary-expression before '>' token
   19 |         queue <node> abc;
      |                    ^
a.cc:19:22: error: 'abc' was not declared in this scope; did you mean 'abs'?
   19 |         queue <node> abc;
      |                      ^~~
      |                      abs
a.cc: In function 'int main()':
a.cc:57:15: error: 'cin' was not declared in this scope
   57 |         while(cin >> m >> n >> t)
      |               ^~~
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    4 | #include <memory.h>
  +++ |+#include <iostream>
    5 | using namespace std;
a.cc:77:17: error: 'cout' was not declared in this scope
   77 |                 cout << cnt << endl;
      |                 ^~~~
a.cc:77:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:77:32: error: 'endl' was not declared in this scope
   77 |                 cout << cnt << endl;
      |                                ^~~~
a.cc:5:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    4 | #include <memory.h>
  +++ |+#include <ostream>
    5 | using namespace std;
Language: C++

#include <cstdio>
#include <iostream>
#include <queue>
#include <map>
#include <string>

using namespace std;

typedef struct P{
    int x;
    int y;
};


int h,w;

const int INF = 100000000;

char feld[101][101];
P ch[11];
int d[101][101];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int sx,sy;
int gx,gy;
int n;
int ans;

int bfs(){
    for(int i=0;i<n;i++){
        P s_xy=ch[i];
        sx=ch[i].x;
        sy=ch[i].y;
        gx=ch[i+1].x;
        gy=ch[i+1].y;
        for(int y=0;y<h;y++)
            for(int x=0;x<w;x++)
                d[y][x]=INF;
            queue<P> que;
            que.push(s_xy);
            d[sy][sx]=0;
            while(!que.empty()){
                P p=que.front();
                que.pop();
                int x=p.x;
                int y=p.y;
                if(x==gx&&y==gy){
                    ans+=d[gy][gx];
                    break;
                }
                for(int i=0;i<4;i++){
                    int nx=x+dx[i];
                    int ny=y+dy[i];
                    if(nx<0||nx>=w||ny<0||ny>=h)continue;
                    if(feld[ny][nx]!='X'&&d[ny][nx]==INF){
                        P n;
                        n.x=nx;
                        n.y=ny;
                        d[ny][nx]=d[y][x]+1;
                        que.push(n);
                    }
                }
            }
        }
        return
}

int main(){
    cin>>w>>h>>n;
    char c;
    for(int y=0;y<h;y++){
        for(int x=0;x<w;x++){
            scanf(" %c",&feld[y][x]);
            c=feld[y][x];
            if(feld[y][x]=='S'){
                ch[0].x=x;
                ch[0].y=y;

            }
            if(c>='1'&&c<='9'){
                ch[c-'0'].x=x;
                ch[c-'0'].y=y;

            }
        }
    }
    bfs();
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc:9:1: warning: 'typedef' was ignored in this declaration
    9 | typedef struct P{
      | ^~~~~~~
a.cc: In function 'int bfs()':
a.cc:66:1: error: expected primary-expression before '}' token
   66 | }
      | ^
a.cc:65:15: error: expected ';' before '}' token
   65 |         return
      |               ^
      |               ;
   66 | }
      | ~