답안 #365689

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
365689 2021-02-12T08:05:01 Z Yomapeed Nautilus (BOI19_nautilus) C++17
100 / 100
273 ms 1260 KB
#include<bits/stdc++.h>
#define pi 3.141592653589793238
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const int N = 5e2;
bitset<N> dp[N], nxt[N], grid[N];
string s, t[N];
int r, c, m;
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        
        cin >> r >> c >> m;
        for(i = 0; i < r; i++){
            cin >> t[i];
            dp[i] = 0, grid[i] = 0;
            for(j = 0; j < c; j++){
                grid[i][j] = (t[i][j]  == '.');
            }
            dp[i] = grid[i];
        }
        cin >> s;
        for(auto u : s){
            for(i = 0; i < r; i++){
                nxt[i] = 0;
            }
            if(u == 'E' || u == '?'){
                for(i = 0; i < r; i++){
                    nxt[i] |= (dp[i] << 1);
                }
            }
            if(u == 'W' || u == '?'){
                for(i = 0; i < r; i++){
                    nxt[i] |= (dp[i] >> 1);
                }
            }
            if(u == 'S' || u == '?'){
                for(i = 1; i < r; i++){
                    nxt[i] |= (dp[i - 1]);
                }
            }
            if(u == 'N' || u == '?'){
                for(i = 0; i < r - 1; i++){
                    nxt[i] |= (dp[i + 1]);
                }
            }
            for(i = 0; i < r; i++){
                dp[i] = (nxt[i] & grid[i]);
            }
        }
        int ans = 0;
        for(i = 0; i < r; i++){
            ans += dp[i].count();
        }
        cout << ans << endl;
    }
    return 0;
}

Compilation message

nautilus.cpp:4: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    4 | #pragma GCC optimization ("O3")
      | 
nautilus.cpp:5: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    5 | #pragma GCC optimization ("unroll-loops")
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 2 ms 364 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 2 ms 364 KB Output is correct
21 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 2 ms 364 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 2 ms 364 KB Output is correct
21 Correct 2 ms 364 KB Output is correct
22 Correct 190 ms 1028 KB Output is correct
23 Correct 187 ms 1004 KB Output is correct
24 Correct 186 ms 1132 KB Output is correct
25 Correct 186 ms 1132 KB Output is correct
26 Correct 204 ms 1004 KB Output is correct
27 Correct 226 ms 1132 KB Output is correct
28 Correct 240 ms 1132 KB Output is correct
29 Correct 240 ms 1028 KB Output is correct
30 Correct 236 ms 1004 KB Output is correct
31 Correct 249 ms 1004 KB Output is correct
32 Correct 261 ms 1132 KB Output is correct
33 Correct 263 ms 1132 KB Output is correct
34 Correct 267 ms 1260 KB Output is correct
35 Correct 263 ms 1132 KB Output is correct
36 Correct 273 ms 1028 KB Output is correct