Submission #1589429
Source Code Expand
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
typedef struct
{
int x, y;
}Point;
int vx[] = { 1, -1, 0, 0 };
int vy[] = { 0, 0, 1, -1 };
int exp(char c[][500], int sx, int sy, int gx, int gy)
{
Point q[25000];
static int f[500][500];
int front = 0, rear = 0, i, j;
for (i = 0; i < 500; i++)
for (j = 0; j < 500; j++)
f[i][j] = -1;
q[front].x = sx;
q[front].y = sy;
f[sy][sx] = 0;
while (front <= rear)
{
int tx = q[front].x, ty = q[front].y;
for (i = 0; i < 4; i++)
if (c[ty + vy[i]][tx + vx[i]] != '#' && f[ty + vy[i]][tx + vx[i]] == -1)
{
f[ty + vy[i]][tx + vx[i]] = f[ty][tx] + 1;
rear++;
q[rear].x = tx + vx[i];
q[rear].y = ty + vy[i];
}
front++;
}
return f[gy][gx];
}
int main()
{
int n, m, i, j, sx, sy, cx, cy, gx, gy;
char c[500][500];
scanf("%d%d", &n, &m);
getchar();
for (i = 0; i < n; i++)
{
for (j = 0; j < m; j++)
if ((c[i][j] = getchar()) == 'S')
{
sx = j;
sy = i;
}
else if (c[i][j] == 'C')
{
cx = j;
cy = i;
}
else if (c[i][j] == 'G')
{
gx = j;
gy = i;
}
getchar();
}
if (exp(c, sx, sy, cx, cy) == -1 || exp(c, cx, cy, gx, gy) == -1)
puts("-1");
else
printf("%d\n", exp(c, sx, sy, cx, cy) + exp(c, cx, cy, gx, gy));
return 0;
}
Submission Info
Submission Time
2017-09-12 18:57:34+0900
Task
C - 自宅からの脱出
User
mafun
Language
C (GCC 5.4.1)
Score
0
Code Size
1384 Byte
Status
RE
Exec Time
99 ms
Memory
1536 KB
Compile Error
./Main.c:14:5: warning: conflicting types for built-in function ‘exp’
int exp(char c[][500], int sx, int sy, int gx, int gy)
^
./Main.c: In function ‘main’:
./Main.c:53:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &n, &m);
^
Judge Result
Set Name
All
Score / Max Score
0 / 100
Status
Set Name
Test Cases
All
input_0.txt, input_1.txt, input_10.txt, input_11.txt, input_12.txt, input_13.txt, input_14.txt, input_15.txt, input_16.txt, input_17.txt, input_18.txt, input_19.txt, input_2.txt, input_20.txt, input_21.txt, input_22.txt, input_23.txt, input_3.txt, input_4.txt, input_5.txt, input_6.txt, input_7.txt, input_8.txt, input_9.txt
Case Name
Status
Exec Time
Memory
input_0.txt
AC
1 ms
1152 KB
input_1.txt
AC
1 ms
1152 KB
input_10.txt
AC
1 ms
1152 KB
input_11.txt
AC
1 ms
1152 KB
input_12.txt
AC
1 ms
1152 KB
input_13.txt
AC
1 ms
1408 KB
input_14.txt
RE
98 ms
1536 KB
input_15.txt
RE
98 ms
1536 KB
input_16.txt
AC
3 ms
1408 KB
input_17.txt
RE
99 ms
1536 KB
input_18.txt
AC
2 ms
1280 KB
input_19.txt
AC
2 ms
1280 KB
input_2.txt
AC
1 ms
1152 KB
input_20.txt
AC
2 ms
1280 KB
input_21.txt
RE
97 ms
1536 KB
input_22.txt
AC
3 ms
1408 KB
input_23.txt
AC
3 ms
1408 KB
input_3.txt
AC
1 ms
1152 KB
input_4.txt
AC
1 ms
1152 KB
input_5.txt
AC
1 ms
1152 KB
input_6.txt
AC
1 ms
1152 KB
input_7.txt
AC
1 ms
1152 KB
input_8.txt
AC
1 ms
1152 KB
input_9.txt
AC
1 ms
1152 KB