# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
515693 |
2022-01-19T13:34:05 Z |
Hacv16 |
Patkice (COCI20_patkice) |
C++17 |
|
1000 ms |
332 KB |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAX = 115;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int VAR[4] = {-1, 1, 0, 0};
#define pb push_back
#define sz(x) (int) x.size()
#define fr first
#define sc second
#define mp make_pair
#define all(x) x.begin(), x.end()
int n, m, dx, dy, ix, iy;
bool seen[MAX][MAX];
char s[MAX][MAX];
void setIO(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
char conv(int x, int y, int nx, int ny){
if(nx == x + 1 && ny == y) return 'S';
if(nx == x - 1 && ny == y) return 'N';
if(nx == x && ny == y + 1) return 'E';
return 'W';
}
pii pos(char c, int x, int y){
if(c == '^') return {x - 1, y};
if(c == 'v') return {x + 1, y};
if(c == '>') return {x, y + 1};
return {x, y - 1};
}
void dfs(int x, int y){
seen[x][y]= true;
pii nw = pos(s[x][y], x, y);
if(s[nw.fr][nw.sc] != '.' && s[x][y] != 'x'){
dfs(nw.fr, nw.sc);
}
}
int main(){
setIO();
memset(s, '.', sizeof(s));
cin >> n >> m;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin >> s[i][j];
if(s[i][j] == 'o') dx = i, dy = j;
else if(s[i][j] == 'x') ix = i, iy = j;
}
}
for(int i = 0, j = 3; i < 4; i++, j--){
int nx = dx + VAR[i], ny = dy + VAR[j];
if(s[nx][ny] == '.') continue;
dfs(nx, ny);
if(seen[ix][iy]){
cout << ":)" << '\n' << conv(dx, dy, nx, ny) << '\n';
return 0;
}
}
cout << ":(" << '\n';
return 0;
}
Compilation message
patkice.cpp: In function 'void setIO()':
patkice.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
28 | freopen("input.txt", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
patkice.cpp:29:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
29 | freopen("output.txt", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1081 ms |
332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1083 ms |
332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |