为啥就过了几个测试点
查看原帖
为啥就过了几个测试点
1551675
pan1188楼主2025/1/17 17:10
    #include<stdio.h>
    #include<string.h>
    #include<stdbool.h>
    struct cow {
	   int x; 
	   int y;
	   int face;
            }c,f;
      int dx[4] = { -1,0,1,0 }, dy[4] =           {0,1,0,-1}; 
    int main() {
	int a[15][15];
	char h; 
	int time = 0;
	bool  mark[11][11][4][11][11][4] = {0};
	for (int i = 1; i <= 10; i++) {
		for (int j = 1; j <= 10; j++) {
			h = getchar(); if (h == '.')a[i][j] = 1;
			if (h == 'C') { c.x = i; c.y = j;       c.face = 0; }
			if (h == 'F') { f.x = i; f.y = j; f. face = 0; }
		}getchar();
	}
	while (c.x != f.x || c.y != f.y) {
		time++;
		if (a[c.x + dx[c.face]][c.y + dy[c.face]] == 1) {
		c.x += dx[c.face];
		c.y += dy[c.face];
		
	}
	else {
     c.face = (c.face + 1) % 4;
	}
		if (a[f.x + dx[f.face]][f.y + dy[f.face]] == 1) {
			f.x += dx[f.face];
			f.y += dy[f.face];

		}
		else {
			f.face = (f.face + 1) % 4;
		}
		if (mark[c.x][c.y][c.face][f.x][f.y][f.face]==1) { printf("0"); return 0; }
		else  mark[c.x][c.y][c.face][f.x][f.y][f.face] = 1;     
	}
	printf("%d", time);
	return 0;
> }```
2025/1/17 17:10
加载中...