Submission #895532

#TimeUsernameProblemLanguageResultExecution timeMemory
895532vjudge1Nautilus (BOI19_nautilus)C++17
100 / 100
214 ms1104 KiB
//GOAL : BECOME A MASTER //cf : Mali //Toktarbek Muhammedali 10B //Esyk BIL // #include <bits/stdc++.h> #include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <queue> #include <stack> #include <string> #include <bitset> #include <cstdio> #include <limits> #include <vector> #include <climits> #include <cstring> #include <cstdlib> #include <fstream> #include <numeric> #include <sstream> #include <cassert> #include <iomanip> #include <iostream> #include <algorithm> #include <stdio.h> #include <fstream> using namespace std; #define fast() ios_base::sync_with_stdio(0),cin.tie(0) #define int long long #define F first #define S second // const int N = 1e6 + 10; // const long long INF = 1e18 + 1; // const int mod = 1e9 + 7; using namespace std; bitset<600>a[600] , b[600] , E[600] , W[600] , S[600] , N[600] , nw[600]; void goat(){ char x; string s; int n , m , k; cin >> n >> m >> k; for (int i = 1 ; i <= n ; i ++){ for (int j = 1 ; j <= m ; j ++){ cin >> x; if (x == '.'){ a[i][j] = 1; b[i][j] = 1; } } } cin >> s; s = '.' + s; for (int i = 1 ; i <= k ; i ++){ if (s[i] == 'E'){ for (int j = 1 ; j <= n ; j ++)a[j] = (a[j] << 1); for (int j = 1 ; j <= n ; j ++)a[j] &= b[j]; } else if (s[i] == 'W'){ for (int j = 1 ; j <= n ; j ++)a[j] = (a[j] >> 1); for (int j = 1 ; j <= n ; j ++)a[j] &= b[j]; } else if (s[i] == 'S'){ for (int j = n ; j >= 1 ; j --)a[j] = a[j-1]; for (int j = 1 ; j <= n ; j ++)a[j] &= b[j]; } else if (s[i] == 'N'){ for (int j = 1 ; j <= n ; j ++)a[j] = a[j+1]; for (int j = 1 ; j <= n ; j ++)a[j] &= b[j]; } else { for (int i = 1 ; i <= n ; i ++){ N[i] = a[i]; W[i] = a[i]; S[i] = a[i]; E[i] = a[i]; } // for (int j = 1 ; j <= n ; j ++)N[j] = N[j+1]; for (int j = 1 ; j <= n ; j ++)N[j] &= b[j]; // for (int j = n ; j >= 1 ; j --)S[j] = S[j-1]; for (int j = 1 ; j <= n ; j ++)S[j] &= b[j]; // for (int j = 1 ; j <= n ; j ++)W[j] = (W[j] >> 1); for (int j = 1 ; j <= n ; j ++)W[j] &= b[j]; // for (int j = 1 ; j <= n ; j ++)E[j] = (E[j] << 1); for (int j = 1 ; j <= n ; j ++)E[j] &= b[j]; // for (int i = 1 ; i <= n ; i ++){ nw[i] = (N[i] | W[i] | E[i] | S[i]); a[i] = nw[i]; } } } int ans = 0; for (int i = 1 ; i <= n ; i ++){ for (int j = 1 ; j <= m ; j ++){ if (a[i][j] == 1)ans++; } } cout << ans << endl; } signed main () { fast(); ///S //E W ///N // freopen("B.in", "r", stdin); // freopen("B.out", "w", stdout); // int T; // cin >> T; // for (int i = 1 ; i <= T ; i ++){ goat(); // } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...