Submission #496374

#TimeUsernameProblemLanguageResultExecution timeMemory
496374MukhitaliNautilus (BOI19_nautilus)C++17
0 / 100
1 ms332 KiB
//bit chass 1 #include <bits/stdc++.h> #define x first #define y second #define el "\n" #define ll long long #define pb push_back #define pll pair <ll, ll> #define pii pair <int, int> #define all(x) x.begin(), x.end() #define lcm(x,y) x * y / __gcd(x, y) #define ibase ios_base::sync_with_stdio(0), cin.tie(0) using namespace std; const int N = 3e5 + 5, inf = 1e9 + 7, M = 2e6, MM = 2e6 + 5, K = 300; const ll MI = 2e18; const double P = 3.14; string s[505]; void solve() { int r, c, m, x = 0, y = 0; cin >> r >> c >> m; for (int i = 0; i < r; i++) cin >> s[i]; int ans= 0; string a; cin >> a; for (int i = 0; i < m; i++) { if (a[i] == 'N') x--; if (a[i] == 'S') x++; if (a[i] == 'W') y--; if (a[i] == 'E') y++; } for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { if (0 <= i + x && i + x < r && 0 <= j + y && j + y < c) { bool ok = 0; int q = i, w = j; for (int k = 0; k < m; k++) { if (a[i] == 'N') { if (q == 0 || s[q - 1][w] == '#') break; q--; } if (a[i] == 'S') { q++; if (q == r || s[q][w] == '#') break; } if (a[i] == 'W') { if (w == 0 || s[q][w - 1] == '#') break; w--; } if (a[i] == 'E') { w++; if (w == c || s[q][w] == '#') break; } if (i == m - 1) ok = 1; } if (ok) ans++; } } } cout << ans; } int main() { ibase; int T = 1; // cin >> T; for (int i = 1; i <= T; i++) { // cout << "Case " << i << ": "; solve(); cout << el; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...