Submission #871702

#TimeUsernameProblemLanguageResultExecution timeMemory
871702AcanikolicNautilus (BOI19_nautilus)C++14
100 / 100
155 ms856 KiB
#include <bits/stdc++.h> #define int long long #define pb push_back #define F first #define S second using namespace std; const long long N = 510; const long long mod = 1e9+7; const long long inf = 1e18; const int K = 510; bitset<K>pravi[N],resenje[N]; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int r,c,m; cin >> r >> c >> m; for(int i=1;i<=r;i++) { for(int j=1;j<=c;j++) { char x; cin >> x; pravi[i][j] = 0; if(x == '.') pravi[i][j] = 1; resenje[i][j] = 1; } resenje[i] = pravi[i] & resenje[i]; } string s; cin >> s; for(int sta=0;sta<s.size();sta++) { /* for(int i=1;i<=r;i++) { if(s[sta] == 'N') { resenje[i] = pravi[i] & resenje[i+1]; }else if(s[sta] == 'S') { resenje[i] = pravi[i] & resenje[i-1]; }else if(s[sta] == 'W') { resenje[i] = pravi[i] & (resenje[i] >> 1); }else if(s[sta] == 'E') { resenje[i] = pravi[i] & (resenje[i] << 1); }else { resenje[i] = pravi[i] & resenje[i+1]; resenje[i] |= pravi[i] & resenje[i-1]; resenje[i] |= pravi[i] & (resenje[i] << 1); resenje[i] |= pravi[i] & (resenje[i] >> 1); } }*/ if(s[sta] == 'N') { // gore for(int i=1;i<=r;i++) resenje[i] = pravi[i] & resenje[i+1]; }else if(s[sta] == 'S') { for(int i=r;i>=1;i--) resenje[i] = pravi[i] & resenje[i-1]; }else if(s[sta] == 'W') { for(int i=1;i<=r;i++) resenje[i] = pravi[i] & (resenje[i] >> 1); }else if(s[sta] == 'E') { for(int i=1;i<=r;i++) resenje[i] = pravi[i] & (resenje[i] << 1); }else { bitset<K>tmp[N]; for(int i=1;i<=r;i++) { tmp[i] |= pravi[i] & resenje[i+1]; tmp[i] |= pravi[i] & (resenje[i] >> 1); tmp[i] |= pravi[i] & (resenje[i] << 1); } for(int i=r;i>=1;i--) tmp[i] |= pravi[i] & (resenje[i-1]); for(int i=1;i<=r;i++) resenje[i] = tmp[i]; } } int res = 0; for(int i=1;i<=r;i++) { for(int j=1;j<=c;j++) res += resenje[i][j]; } cout << res; return 0; }

Compilation message (stderr)

nautilus.cpp: In function 'int main()':
nautilus.cpp:42:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  for(int sta=0;sta<s.size();sta++) {
      |                ~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...