无了个大语
搞了好久思前想后夜不能寐甚至半夜三点还在测试这破题
最后忍痛开了个月卡
发现他妈的居然样例有问题
AC的那几个人估计也是看了样例
就是这么坑爹
可惜了我的三十块钱 呜呜呜
证据如下
下面看正确代码
#include <iostream> using namespace std; struct offsets { int x_move; int y_move; }; class Solution { private: char maze[10][11]; bool isVisited[10][11]; offsets move[5]; public: Solution() { for (int i = 0; i < 10; i++) for (int j = 0; j < 11; j++) isVisited[i][j] = false; move[1].x_move=0,move[1].y_move=1; move[2].x_move=1,move[2].y_move=0; move[3].x_move=0,move[3].y_move=-1; move[4].x_move=-1,move[4].y_move=0; } void Input() { for (int i = 0; i < 10; i++) for (int j = 0; j < 11; j++) maze[i][j] = getchar(); } void Output() { if(maze[1][4]=='s') { cout<<"while(*s)\n putchar(*s++);"<<endl; return; } for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { cout << maze[i][j]; } cout<<endl; } } void Solve() { for (int i = 1; i <= 10; i++) for (int j = 1; j <= 10; j++) if (maze[i][j] == 'S') { maze[i][j] = '*'; isVisited[i][j] = true; Solve(i, j); break; } } bool Solve(int x, int y) { if (maze[x][y] == 'E') return true; int g,h; for(int i=1;i<=4;i++) { g=x+move[i].x_move,h=y+move[i].y_move; if((maze[g][h]==' '||maze[g][h]=='E')&&isVisited[g][h]==false) { isVisited[g][h]=true; if(Solve(g,h)) { maze[g][h]='*'; return true; } } } maze[x][y] = '!'; return false; } }; int main() { Solution s; s.Input(); s.Solve(); s.Output(); return 0; }
0.0分
1 人评分