Submission #132078

#TimeUsernameProblemLanguageResultExecution timeMemory
132078youssefbou62Nautilus (BOI19_nautilus)C++14
100 / 100
266 ms158840 KiB
#pragma GCC optimize("Ofast") #pragma GCC target("sse4") #include <bits/stdc++.h> using namespace std; #define mp make_pair #define fi first #define se second #define all(v) v.begin(),v.end() #define allarr(a) a , a + n #define ll long long #define ull unsigned long long #define pb push_back #define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL) typedef pair<int, int> pi; typedef pair<ll,ll> pll; typedef pair<int,pi> trp ; typedef vector<pi> vpi; typedef vector<pll> vpll ; // int ab (int x ) { return (x>0?x:-x); } const int N = 505 , M = 5005 ; int R , C , m ; bitset<N> dp[M][N] , a[N]; string seq ; void direction(int& i, int& j , char c ){ if( c =='N'){ i-- ; }else if( c =='S'){ i++; }else if( c =='E'){ j++ ; }else if( c =='W'){ j--; } } bool valid (int i , int j ){ return ( i >= 0 && j >= 0 && i < R && j < C && a[i][j]!='#') ; } int main(){ scanf("%d%d%d\n",&R,&C,&m); for(int i = 0 ; i < R ; i++ ){ for(int j = 0 ; j < C ; j++ ){ char c ; scanf(" %c",&c); a[i][j] = (c=='.') ; } } for(int i = 0 ; i < R ; i++ ){ for(int j = 0 ; j < C ; j++ ) dp[0][i][j] = a[i][j]; } cin >> seq ; string dir = "NSWE"; for(int moves = 0 ; moves < m ; moves++){ for(int i=0 ; i < R ; i++ ){ char c = seq[moves] ; if( (c=='N' || c=='?') && i ){ dp[moves+1][i-1] = (dp[moves][i]|dp[moves+1][i-1])&a[i-1]; }if(c=='S'|| c=='?'){ dp[moves+1][i+1] = (dp[moves][i]|dp[moves+1][i+1])&a[i+1]; }if(c=='E'|| c=='?'){ dp[moves+1][i] = (dp[moves+1][i]|(dp[moves][i]<<1))&a[i]; }if( c=='W' || c=='?'){ dp[moves+1][i] = (dp[moves+1][i]|(dp[moves][i]>>1))&a[i]; } } } int ans = 0 ; for(int i = 0 ; i < R ; i++ )ans += dp[m][i].count(); cout << ans << endl ; }

Compilation message (stderr)

nautilus.cpp: In function 'int main()':
nautilus.cpp:47:6: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf("%d%d%d\n",&R,&C,&m); 
 ~~~~~^~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:51:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %c",&c);
   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...