Submission #914705

#TimeUsernameProblemLanguageResultExecution timeMemory
914705vjudge1Patkice (COCI20_patkice)C++17
30 / 50
1 ms348 KiB
#include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag, // __gnu_pbds::tree_order_statistics_node_update > ordered_set; // #include "debugging.h" using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<ll> vll; typedef vector<vi> vvi; typedef vector<vii> vvii; #define pb push_back #define mp make_pair #define all(a) (a).begin(), (a).end() #define f first #define s second #define endl '\n' #define fr(i, x) for (ll i = 0; i < x; i++) #define fr1(i, x) for (ll i = 1; i <= x; i++) #define FOR(i, x, y) for (ll i = x; i < y; i++) #define lcm(a, b) (a * b) / __gcd(a, b) #define sqr(x) ((x) * (x)) #define cube(x) ((x) * (x) * (x)) #define dbg(v) cerr << "Line(" << __LINE__ << ") -> " << #v << " = " << (v) << endl; #define show(v) cerr << v << " "; #define INT(n) \ int n; \ cin >> n; const ll INF = LLONG_MAX / 2; const double PI = acos(-1); const int MOD = 1e9 + 7; int n, m, x, y; vector<vector<char>> sea(101, vector<char>(101, '.')); int travel(int x, int y) { int dist = 0; while (true) { if (sea[x][y] == '^') x--; else if (sea[x][y] == 'v') x++; else if (sea[x][y] == '>') y++; else if (sea[x][y] == '<') y--; else if (sea[x][y] == 'x') return dist; else return 1e6; dist++; } } int main() { std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m; fr1(i, n) { fr1(j, m) { cin >> sea[i][j]; if (sea[i][j] == 'o') { x = i; y = j; } } } int dist, min_dist = 1e6; char ans = '$'; dist = travel(x, y + 1); if (dist < min_dist) { min_dist = dist; ans = 'E'; } dist = travel(x, y - 1); if (dist < min_dist) { min_dist = dist; ans = 'W'; } dist = travel(x + 1, y); if (dist < min_dist) { min_dist = dist; ans = 'S'; } dist = travel(x - 1, y); if (dist < min_dist) { min_dist = dist; ans = 'N'; } if (ans != '$') cout << ":)\n" << ans << endl; else cout << ":(\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...