Submission #735111

# Submission time Handle Problem Language Result Execution time Memory
735111 2023-05-03T14:56:49 Z Farhan_HY Patkice (COCI20_patkice) C++14
0 / 50
18 ms 31700 KB
#include <bits/stdc++.h>
#define F first 
#define S second 
#define T int tc; cin >> tc; while(tc--) 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
using namespace std;
const int inf = 1e18;
const int N = 1e6 + 5;
const int M = 505; 
const int LOG = 32;
const int CHAR = 26;
const int mod = 1e9 + 7;
const int mod2 = 998244353;
const float pi = atan(1) * 4;
const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, 1, -1};
const char d[] = {'W', 'E', 'S', 'N'};
int n, m;
string s[N];
bool vis[M][M];
bool inside(int x, int y) {
    return x >= 1 && y >= 1 && x <= m && y <= n;
}

bool ok(int j, int i) {
    if (vis[i][j]) return 0;
    vis[i][j] = 1;
    if (!inside(j, i)) return 0;
    if (s[i][j] == '.') return 0;
    if (s[i][j] == 'x') return 1;
    if (s[i][j] == '>') return ok(j + 1, i);
    if (s[i][j] == '<') return ok(j - 1, i);
    if (s[i][j] == 'v') return ok(j, i + 1);
    return ok(j, i - 1);
}

main() {
    IOS
    cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> s[i], s[i] = '.' + s[i];
    string ans;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if (s[i][j] == 'o') {
                for(int ii = 0; ii <= n + 1; ii++) for(int jj = 0; jj <= m + 1; jj++) vis[i][j] = 0;
                for(int k = 0; k < 4; k++) {
                    if (inside(dx[k] + j, dy[k] + i)) {
                        if (ok(dx[k] + j, dy[k] + i)) ans = d[k];
                    }
                }
            }
        }
    }
    if (ans.size() == 0) cout << ":(\n";
    else cout << ":)\n";
    cout << ans;
}

Compilation message

patkice.cpp:7:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
    7 | const int inf = 1e18;
      |                 ^~~~
patkice.cpp:37:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   37 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 15 ms 31596 KB Output is correct
2 Correct 18 ms 31620 KB Output is correct
3 Incorrect 16 ms 31700 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 31644 KB Output isn't correct
2 Halted 0 ms 0 KB -