# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
486308 | Christopher_ | Patkice (COCI20_patkice) | C++17 | 1 ms | 204 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
int n, m;
cin >> n >> m;
vector<string> g(n);
pair<int, int> st, fi;
vector<vector<bool>> vis(n, vector<bool>(m));
for (int i = 0; i < n; ++i) {
cin >> g[i];
for (int j = 0; j < m; ++j) {
if (g[i][j] == 'o') {
st = {i, j};
} else if (g[i][j] == 'x') {
fi = {i, j};
}
}
}
auto e = [&](int x, int y) {
if (x >= 0 && x < n && y >= 0 && y < m && !vis[x][y] && g[x][y] != '.') return true;
return false;
};
int x, y;
x = st.first, y = st.second;
x++;
while (x != fi.first || y != fi.second) {
if (!e(x, y)) {
break;
}
vis[x][y] = true;
if (g[x][y] == '^') {
x--;
} else if (g[x][y] == 'v') {
x++;
} else if (g[x][y] == '>') {
y++;
} else {
--y;
}
}
if (x == fi.first && y == fi.second) {
return cout << ":)" << '\n' << "S" << '\n', 0;
}
x = st.first, y = st.second;
x--;
while (x != fi.first || y != fi.second) {
if (!e(x, y)) {
break;
}
vis[x][y] = true;
if (g[x][y] == '^') {
x--;
} else if (g[x][y] == 'v') {
x++;
} else if (g[x][y] == '>') {
y++;
} else {
--y;
}
}
if (x == fi.first && y == fi.second) {
return cout << ":)" << '\n' << "N" << '\n', 0;
}
x = st.first, y = st.second;
y++;
while (x != fi.first || y != fi.second) {
if (!e(x, y)) {
break;
}
vis[x][y] = true;
if (g[x][y] == '^') {
x--;
} else if (g[x][y] == 'v') {
x++;
} else if (g[x][y] == '>') {
y++;
} else {
--y;
}
}
if (x == fi.first && y == fi.second) {
return cout << ":)" << '\n' << "R" << '\n', 0;
}
x = st.first, y = st.second;
y--;
while (x != fi.first || y != fi.second) {
if (!e(x, y)) {
break;
}
vis[x][y] = true;
if (g[x][y] == '^') {
x--;
} else if (g[x][y] == 'v') {
x++;
} else if (g[x][y] == '>') {
y++;
} else {
--y;
}
}
if (x == fi.first && y == fi.second) {
return cout << ":)" << '\n' << "L" << '\n', 0;
}
cout << ":(" << '\n';
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |