50分求助
查看原帖
50分求助
1003102
Carl_T_C楼主2024/9/9 14:15
#include<iostream>
using namespace std;	

char ma[110][110],fx;
int n,m,z=1;
struct node{
	int x,y;
}b[2024];

int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m>>fx;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>ma[i][j];
			if(ma[i][j]=='o'){
				b[z].x=i;
				b[z].y=j;
				z++;
			}
		}
	}
	while(z){
		if(fx=='^'){
			for(int i=b[z].x;i>=1;i--){
				if(ma[i][b[z].y]=='x'){
					cout<<"GG";
					return 0;
				}
			}
		}else if(fx=='v'){
			for(int i=b[z].x;i<=n;i++){
				if(ma[i][b[z].y]=='x'){
					cout<<"GG";
					return 0;
				}
			}
		}else if(fx=='<'){
			for(int i=b[z].y;i>=1;i--){
				if(ma[b[z].y][i]=='x'){
					cout<<"GG";
					return 0;
				}
			}
		}else{
			for(int i=b[z].y;i<=m;i++){
				if(ma[b[z].x][i]=='x'){
					cout<<"GG";
					return 0;
				}
			}
		}
		z--;
	}
	cout<<"OK";
    return 0;
}

明天才看

2024/9/9 14:15
加载中...