| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 366837 | topovik | Patkice (COCI20_patkice) | C++14 | 1 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
using namespace std;
typedef long long ll;
const ll oo = 1e9;
const ll N = 1e3;
vector <pair<vector <char>, bool> > ans;
bool mrk[N][N];
string s[N];
int n, m;
int sx, sy;
bool good(int x, int y)
{
return (x >= 0 && y >= 0 && x < n && y < m);
}
void Rec(int x, int y)
{
if (good(x, y) && mrk[x][y] || s[x][y] == '.' || s[x][y] == 'o')
{
ans.back().s = 0;
return;
}
if (s[x][y] == 'x') return;
mrk[x][y] = 1;
if (s[x][y] == '^') x--;
if (s[x][y] == 'v') x++;
if (s[x][y] == '<') y--;
if (s[x][y] == '>') y++;
ans.back().f.pb('v');
Rec(x, y);
}
void clear()
{
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++) mrk[i][j] = 0;
}
void Check()
{
ans.pb({{}, 1});
ans.back().f.pb('N');
clear();
Rec(sx - 1, sy);
ans.pb({{}, 1});
ans.back().f.pb('S');
clear();
Rec(sx + 1, sy);
ans.pb({{}, 1});
ans.back().f.pb('E');
clear();
Rec(sx, sy + 1);
ans.pb({{}, 1});
ans.back().f.pb('W');
clear();
Rec(sx, sy - 1);
}
bool cmp(pair<vector <char>, bool> _a, pair<vector <char>, bool> _b)
{
if (!_b.s) return 1;
if (!_a.s) return 0;
if (_a.f.size() != _b.f.size()) return _a.f.size() < _b.f.size();
return _a.f[0] < _b.f[0];
}
int main() {
ios_base::sync_with_stdio(0);
iostream::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for (int i = 0; i < n; i++) cin >> s[i];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
if (s[i][j] == 'o') sx = i, sy = j;
Check();
bool g = 0;
for (int i = 0; i < ans.size(); i++) g = g || ans[i].s;
if (!g) cout << ":(";
else
{
cout << ":)\n";
char ch = 'Z';
for (int i = 0; i < ans.size(); i++)
if (ans[i].s) ch = min(ch, ans[i].f[0]);
cout << ch;
}
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
