Submission #721599

#TimeUsernameProblemLanguageResultExecution timeMemory
721599n0sk1llNautilus (BOI19_nautilus)C++14
100 / 100
232 ms724 KiB
#include <bits/stdc++.h> #define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0) #define mp make_pair #define xx first #define yy second #define pb push_back #define pf push_front #define popb pop_back #define popf pop_front #define all(x) (x).begin(),(x).end() #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++) #define fff(i,a,b) for (int (i) = (a); (i) <= b; (i)++) #define bff(i,a,b) for (int (i) = (b)-1; (i) >= (a); (i)--) #define bfff(i,a,b) for (int (i) = (b); (i) >= (a); (i)--) using namespace std; long double typedef ld; unsigned int typedef ui; long long int typedef li; pair<int,int> typedef pii; pair<li,li> typedef pli; pair<ld,ld> typedef pld; vector<vector<int>> typedef graph; unsigned long long int typedef ull; //const int mod = 998244353; const int mod = 1000000007; //Note to self: Check for overflow bitset<512> tab[512]; bitset<512> cur[512]; bitset<512> pom[512]; bitset<512> nula; int solve(string &command, int n, int m) { ff(i,0,n) cur[i]=tab[i]; for (auto c : command) { if (c=='E') { ff(i,0,n) cur[i]=((cur[i]<<1)&tab[i]); } else if (c=='W') { ff(i,0,n) cur[i]=((cur[i]>>1)&tab[i]); } else if (c=='N') { ff(i,0,n) cur[i]=(cur[i+1]&tab[i]); } else if (c=='S') { bff(i,1,n) cur[i]=(cur[i-1]&tab[i]); cur[0]=nula; } else { ff(i,0,n) pom[i]=0; ff(i,0,n) pom[i]|=(cur[i]<<1); ff(i,0,n) pom[i]|=(cur[i]>>1); ff(i,1,n) pom[i]|=(cur[i-1]); ff(i,0,n-1) pom[i]|=(cur[i+1]); ff(i,0,n) cur[i]=(pom[i]&tab[i]); } } int ret=0; ff(i,0,n) ret+=(cur[i].count()); return ret; } int main() { FAST; int n,m,q; cin>>n>>m>>q; ff(i,0,n) { string s; cin>>s; ff(j,0,m) tab[i][j]=(s[j]=='.'); } string command; cin>>command; cout<<solve(command,n,m); }

Compilation message (stderr)

nautilus.cpp: In function 'int solve(std::string&, int, int)':
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:44:5: note: in expansion of macro 'ff'
   44 |     ff(i,0,n) cur[i]=tab[i];
      |     ^~
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:49:13: note: in expansion of macro 'ff'
   49 |             ff(i,0,n) cur[i]=((cur[i]<<1)&tab[i]);
      |             ^~
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:53:13: note: in expansion of macro 'ff'
   53 |             ff(i,0,n) cur[i]=((cur[i]>>1)&tab[i]);
      |             ^~
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:57:13: note: in expansion of macro 'ff'
   57 |             ff(i,0,n) cur[i]=(cur[i+1]&tab[i]);
      |             ^~
nautilus.cpp:14:29: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   14 | #define bff(i,a,b) for (int (i) = (b)-1; (i) >= (a); (i)--)
      |                             ^
nautilus.cpp:61:13: note: in expansion of macro 'bff'
   61 |             bff(i,1,n) cur[i]=(cur[i-1]&tab[i]);
      |             ^~~
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:66:13: note: in expansion of macro 'ff'
   66 |             ff(i,0,n) pom[i]=0;
      |             ^~
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:67:13: note: in expansion of macro 'ff'
   67 |             ff(i,0,n) pom[i]|=(cur[i]<<1);
      |             ^~
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:68:13: note: in expansion of macro 'ff'
   68 |             ff(i,0,n) pom[i]|=(cur[i]>>1);
      |             ^~
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:69:13: note: in expansion of macro 'ff'
   69 |             ff(i,1,n) pom[i]|=(cur[i-1]);
      |             ^~
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:70:13: note: in expansion of macro 'ff'
   70 |             ff(i,0,n-1) pom[i]|=(cur[i+1]);
      |             ^~
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:71:13: note: in expansion of macro 'ff'
   71 |             ff(i,0,n) cur[i]=(pom[i]&tab[i]);
      |             ^~
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:76:5: note: in expansion of macro 'ff'
   76 |     ff(i,0,n) ret+=(cur[i].count());
      |     ^~
nautilus.cpp: In function 'int main()':
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:86:5: note: in expansion of macro 'ff'
   86 |     ff(i,0,n)
      |     ^~
nautilus.cpp:12:28: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   12 | #define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
      |                            ^
nautilus.cpp:89:9: note: in expansion of macro 'ff'
   89 |         ff(j,0,m) tab[i][j]=(s[j]=='.');
      |         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...