제출 #1135204

#제출 시각아이디문제언어결과실행 시간메모리
1135204alir3za_zar3Nautilus (BOI19_nautilus)C++20
66 / 100
1093 ms1092 KiB
// Alir3za.Zar3 -> Shiraz , Iran #include <bits/stdc++.h> using namespace std; #define loop(i , l , r) for (int i=l; i<=r; i+=1) #define arc(i , r , l) for (int i=r; i>=l; i-=1) const int N = 5e2+7; bool dp[2][N][N]; string s,t[N]; signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int r,c,m; cin >> r >> c >> m; loop(i,0,r-1) { cin >> t[i]; loop(j,0,c-1) { if (t[i][j]=='.'){ dp[0][i][j]=1; } } } cin >> s; int T=0; loop(k,0,m-1) { T = 1-T; memset(dp[T],0,sizeof(dp[T])); loop(i,0,r-1) { loop(j,0,c-1) { if (t[i][j] == '#'){ continue; } if (i>0 and dp[1-T][i-1][j] and (s[k]=='S' or s[k]=='?')) { dp[T][i][j] = true; } if (j>0 and dp[1-T][i][j-1] and (s[k]=='E' or s[k]=='?')) { dp[T][i][j] = true; } if (i<r-1 and dp[1-T][i+1][j] and (s[k]=='N' or s[k]=='?')) { dp[T][i][j] = true; } if (j<c-1 and dp[1-T][i][j+1] and (s[k]=='W' or s[k]=='?')) { dp[T][i][j] = true; } } } } int out = 0; loop(i,0,r-1) { loop(j,0,c-1) { out += dp[T][i][j]; } } cout << out << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...