求大佬帮助!(关注)
查看原帖
求大佬帮助!(关注)
488827
Super_Supper楼主2022/2/5 18:07

就A了两个Subtask:Link

代码:

#include <iostream>
using namespace std;
const int N = 105;
int n, m, x, y, a[N][N];
char c;
int main() {
  cin >> n >> m >> c;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char s;
      cin >> s;
      a[i][j] = s == 'x';
      if (s == 'o') {
        x = i;
        y = j;
      }
    }
  }
  if (c == '^') {
    for (int i = x; i >= 1; i--) {
      if (a[i][y]) {
        cout << "GG";
        return 0;
      }
    }
    cout << "OK";
  } else if (c == '<') {
    for (int i = y; i >= 1; i--) {
      if (a[x][i]) {
        cout << "GG";
        return 0;
      }
    }
    cout << "OK";
  } else if (c == '>') {
    for (int i = y; i <= m; i++) {
      if (a[x][i]) {
        cout << "GG";
        return 0;
      }
    }
    cout << "OK";
  } else {
    for (int i = x; i <= n; i++) {
      if (a[i][y]) {
        cout << "GG";
        return 0;
      }
    }
    cout << "OK";
  }
  return 0;
}
2022/2/5 18:07
加载中...