Submission #414699

#TimeUsernameProblemLanguageResultExecution timeMemory
414699juggernautNautilus (BOI19_nautilus)C++17
66 / 100
9 ms452 KiB
#include<bits/stdc++.h> #define fr first #define sc second using namespace std; void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} typedef long long ll; #define USING_ORDERED_SET 0 #if USING_ORDERED_SET #include<bits/extc++.h> using namespace __gnu_pbds; template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; #endif template<class T>void umax(T &a,T b){if(a<b)a=b;} template<class T>void umin(T &a,T b){if(b<a)a=b;} #ifdef IOI2021SG #define printl(args...)printf(args) #else #define printl(args...)((void)0) #endif int n,m,q; bool a[105][105]; bool dp[105][105][2]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin>>n>>m>>q; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++){ char ch; cin>>ch; a[i][j]=(ch=='.'); dp[i][j][0]=a[i][j]; } bool xr=1; string s; cin>>s; reverse(s.begin(),s.end()); for(int k=q-1;k>=0;k--){ char ch=s[k]; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if(a[i][j]){ dp[i][j][xr]=0; if(ch=='N'||ch=='?')dp[i][j][xr]|=dp[i+1][j][xr^1]; if(ch=='S'||ch=='?')dp[i][j][xr]|=dp[i-1][j][xr^1]; if(ch=='W'||ch=='?')dp[i][j][xr]|=dp[i][j+1][xr^1]; if(ch=='E'||ch=='?')dp[i][j][xr]|=dp[i][j-1][xr^1]; } xr^=1; } int cnt=0; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++)cnt+=dp[i][j][xr^1]; cout<<cnt; } /* 5 9 7 ...##.... ..#.##..# ..#....## .##...#.. ....#.... WS?EE?? */

Compilation message (stderr)

nautilus.cpp: In function 'void usaco(std::string)':
nautilus.cpp:5:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:5:66: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void usaco(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...