Submission #205304

#TimeUsernameProblemLanguageResultExecution timeMemory
205304MohamedAhmed04Nautilus (BOI19_nautilus)C++14
100 / 100
182 ms1032 KiB
#include <bits/stdc++.h> using namespace std ; const int MAX = 510 ; char arr[MAX][MAX] ; int n , m , k ; bitset<MAX>prv[MAX] , now[MAX] , mask[MAX] ; string s ; int main() { ios_base::sync_with_stdio(0) ; cin.tie(0) ; cin>>n>>m>>k ; for(int i = 0 ; i < n ; ++i) { for(int j = 0 ; j < m ; ++j) { cin>>arr[i][j] ; if(arr[i][j] == '.') now[i][j] = 1 ; else mask[i][j] = 1 ; } mask[i][m] = 1 ; } cin>>s ; for(int j = 0 ; j < k ; ++j) { for(int i = 0 ; i < n ; ++i) prv[i] = now[i] , now[i].reset() ; if(s[j] == 'N' || s[j] == '?') { for(int i = 0 ; i < n-1 ; ++i) now[i] |= prv[i+1] ; } if(s[j] == 'S' || s[j] == '?') { for(int i = 1 ; i < n ; ++i) now[i] |= prv[i-1] ; } if(s[j] == 'W' || s[j] == '?') { for(int i = 0 ; i < n ; ++i) now[i] |= (prv[i] >> 1) ; } if(s[j] == 'E' || s[j] == '?') { for(int i = 0 ; i < n ; ++i) now[i] |= (prv[i] << 1) ; } for(int i = 0 ; i < n ; ++i) { now[i] |= mask[i] ; now[i] ^= mask[i] ; } } int ans = 0 ; for(int i = 0 ; i < n ; ++i) ans += now[i].count() ; return cout<<ans<<"\n" , 0 ; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...