Submission #889831

#TimeUsernameProblemLanguageResultExecution timeMemory
889831vjudge1Nautilus (BOI19_nautilus)C++17
29 / 100
1039 ms2652 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include<bits/stdc++.h> #define ll long long #define F first #define S second #define pb push_back #define pf push_front #define ppb pop_back #define ppf pop_front #define all(x) x.begin(), x.end() #define sz(x) x.size() #define forik(x) ll i = 1; i <= x; i++ // (a mod 1e9) / (b mod 1e9) = a * (b^1e9) using namespace std; ll a, b, c, e, t, n, m, k; char p[2001][2001]; string s; void rec (ll x, ll y, ll a = 0){ // cout << a << '\n'; // cout << x << ' ' << y << ' ' << a << '\n'; if (p[x][y] == '#'){ return; } if (a == k){ b++; return; } if (s[a] == 'N'){ rec (x - 1, y, a + 1); } else if (s[a] == 'S'){ rec (x + 1, y, a + 1); } else if (s[a] == 'W'){ rec (x, y - 1, a + 1); } else if (s[a] == 'E'){ rec (x, y + 1, a + 1); } else{ rec (x + 1, y, a + 1); rec (x, y - 1, a + 1); rec (x - 1, y, a + 1); rec (x, y + 1, a + 1); } } signed main (){ //freopen (".in", "r", stdin); // freopen (".out", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m >> k; for (int i = 0; i <= n + 1; i++){ for (int y = 0; y <= m + 1; y++){ p[i][y] = '#'; } } for (int i = 1; i <= n; i++){ for (int y = 1; y <= m; y++){ cin >> p[i][y]; } } cin >> s; b = 0; for (int i = 1; i <= n; i++){ for (int y = 1; y <= m; y++){ if (p[i][y] != '#'){ rec (i, y); } } } cout << b; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...