# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
860213 | 2023-10-12T07:36:06 Z | ReLice | Nautilus (BOI19_nautilus) | C++17 | 173 ms | 160364 KB |
#include <bits/stdc++.h> #define ll int #define str string #define ins insert #define ld long double #define pb push_back #define pf push_front #define pof pop_front() #define pob pop_back() #define lb lower_bound #define ub upper_bound #define endl "\n" #define fr first #define sc second #define sz size() #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define bc back() using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} void start(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const long long inf=1e18+7; const ll mod=998244353; const ll N=130*2;; const ld eps=1e-9; char ch[505][505]; vector <bitset<260005>> dp(5005); void solve(){ ll i,j,q; ll c=0; ll n,m,k; cin>>n>>m>>k; c+=m+2; for(i=1;i<=n;i++){ c++; for(j=1;j<=m;j++){ cin>>ch[i][j]; if(ch[i][j]=='.')dp[0][c]=true; c++; } c++; } str s; cin>>s; for(i=1;i<=(ll)s.sz;i++){ if(s[i-1]=='N') dp[i]=dp[0]&(dp[i-1]>>(m+2)); if(s[i-1]=='S') dp[i]=dp[0]&(dp[i-1]<<(m+2)); if(s[i-1]=='W') dp[i]=dp[0]&(dp[i-1]>>1); if(s[i-1]=='E') dp[i]=dp[0]&(dp[i-1]<<1); if(s[i-1]=='?') dp[i]=((dp[i-1]<<(m+2))|(dp[i-1]>>(m+2))|(dp[i-1]<<1)|(dp[i-1]>>1))&(dp[0]); } cout<<dp[s.sz].count()<<endl; } signed main(){ start(); //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); ll t=1; //cin>>t; while(t--) solve(); } /* */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 159824 KB | Output is correct |
2 | Correct | 19 ms | 159828 KB | Output is correct |
3 | Correct | 18 ms | 159832 KB | Output is correct |
4 | Correct | 22 ms | 160124 KB | Output is correct |
5 | Correct | 20 ms | 159824 KB | Output is correct |
6 | Correct | 19 ms | 159836 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 159824 KB | Output is correct |
2 | Correct | 19 ms | 159828 KB | Output is correct |
3 | Correct | 18 ms | 159832 KB | Output is correct |
4 | Correct | 22 ms | 160124 KB | Output is correct |
5 | Correct | 20 ms | 159824 KB | Output is correct |
6 | Correct | 19 ms | 159836 KB | Output is correct |
7 | Correct | 19 ms | 159832 KB | Output is correct |
8 | Correct | 19 ms | 160056 KB | Output is correct |
9 | Correct | 20 ms | 160052 KB | Output is correct |
10 | Correct | 20 ms | 159844 KB | Output is correct |
11 | Correct | 19 ms | 159836 KB | Output is correct |
12 | Correct | 20 ms | 159836 KB | Output is correct |
13 | Correct | 21 ms | 159868 KB | Output is correct |
14 | Correct | 20 ms | 160028 KB | Output is correct |
15 | Correct | 15 ms | 160080 KB | Output is correct |
16 | Correct | 20 ms | 159836 KB | Output is correct |
17 | Correct | 21 ms | 159836 KB | Output is correct |
18 | Correct | 21 ms | 159832 KB | Output is correct |
19 | Correct | 23 ms | 160248 KB | Output is correct |
20 | Correct | 21 ms | 159904 KB | Output is correct |
21 | Correct | 21 ms | 159836 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 159824 KB | Output is correct |
2 | Correct | 19 ms | 159828 KB | Output is correct |
3 | Correct | 18 ms | 159832 KB | Output is correct |
4 | Correct | 22 ms | 160124 KB | Output is correct |
5 | Correct | 20 ms | 159824 KB | Output is correct |
6 | Correct | 19 ms | 159836 KB | Output is correct |
7 | Correct | 19 ms | 159832 KB | Output is correct |
8 | Correct | 19 ms | 160056 KB | Output is correct |
9 | Correct | 20 ms | 160052 KB | Output is correct |
10 | Correct | 20 ms | 159844 KB | Output is correct |
11 | Correct | 19 ms | 159836 KB | Output is correct |
12 | Correct | 20 ms | 159836 KB | Output is correct |
13 | Correct | 21 ms | 159868 KB | Output is correct |
14 | Correct | 20 ms | 160028 KB | Output is correct |
15 | Correct | 15 ms | 160080 KB | Output is correct |
16 | Correct | 20 ms | 159836 KB | Output is correct |
17 | Correct | 21 ms | 159836 KB | Output is correct |
18 | Correct | 21 ms | 159832 KB | Output is correct |
19 | Correct | 23 ms | 160248 KB | Output is correct |
20 | Correct | 21 ms | 159904 KB | Output is correct |
21 | Correct | 21 ms | 159836 KB | Output is correct |
22 | Correct | 98 ms | 160092 KB | Output is correct |
23 | Correct | 100 ms | 160344 KB | Output is correct |
24 | Correct | 98 ms | 160348 KB | Output is correct |
25 | Correct | 105 ms | 160336 KB | Output is correct |
26 | Correct | 97 ms | 160364 KB | Output is correct |
27 | Correct | 149 ms | 160288 KB | Output is correct |
28 | Correct | 140 ms | 160344 KB | Output is correct |
29 | Correct | 139 ms | 160340 KB | Output is correct |
30 | Correct | 138 ms | 160344 KB | Output is correct |
31 | Correct | 145 ms | 160348 KB | Output is correct |
32 | Correct | 166 ms | 160336 KB | Output is correct |
33 | Correct | 168 ms | 160284 KB | Output is correct |
34 | Correct | 168 ms | 160332 KB | Output is correct |
35 | Correct | 173 ms | 160292 KB | Output is correct |
36 | Correct | 165 ms | 160360 KB | Output is correct |