Submission #448123

#TimeUsernameProblemLanguageResultExecution timeMemory
448123flappybirdPatkice (COCI20_patkice)C++14
30 / 50
1 ms460 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("avx,avx2,fma") using namespace std; typedef long long ll; typedef pair<ll, ll> pll; #define MAX 101010 #define MOD 1000000007 #define ln '\n' ll mp[101][101]; ll vis[101][101]; pll dir[4]; ll R, S; bool c(ll x, ll y) { return (1 <= x && x <= R) && (1 <= y && y <= S); } void init() { ll i, j; for (i = 1; i <= R; i++) { for (j = 1; j <= S; j++) vis[i][j] = 0; } } bool chk(ll x, ll y) { if (vis[x][y]) return 0; vis[x][y] = 1; if (!c(x, y)) return 0; if (mp[x][y] == -1) return 0; if (mp[x][y] >= 4) return 1; return chk(x + dir[mp[x][y]].first, y + dir[mp[x][y]].second); } signed main() { cin >> R >> S; ll i, j; dir[0] = { -1, 0 }; dir[1] = { 0, 1 }; dir[2] = { 1, 0 }; dir[3] = { 0, -1 }; vector<string> input; for (i = 1; i <= R; i++) { string s; cin >> s; input.push_back(s); } map<char, ll> asdf; asdf['.'] = -1; asdf['^'] = 0; asdf['>'] = 1; asdf['v'] = 2; asdf['<'] = 3; asdf['o'] = 4; asdf['x'] = 5; pll st, en; for (i = 1; i <= R; i++) { for (j = 1; j <= S; j++) { mp[i][j] = asdf[input[i - 1][j - 1]]; if (mp[i][j] == 4) st = { i, j }; } } ll ans = -1; init(); mp[st.first][st.second] = 0; if (chk(st.first, st.second)) ans = 0; init(); mp[st.first][st.second] = 1; if (chk(st.first, st.second)) ans = 1; init(); mp[st.first][st.second] = 2; if (chk(st.first, st.second)) ans = 2; init(); mp[st.first][st.second] = 3; if (chk(st.first, st.second)) ans = 3; if (ans == -1) { cout << ":(" << ln; return 0; } cout << ":)" << ln; if (ans == 0) cout << 'N' << ln; if (ans == 1) cout << 'E' << ln; if (ans == 2) cout << 'S' << ln; if (ans == 3) cout << 'W' << ln; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...