답안 #154289

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
154289 2019-09-20T09:49:58 Z kungfulon Nautilus (BOI19_nautilus) C++14
100 / 100
200 ms 992 KB
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a;i <= b;i++)
#define repd(i,a,b) for(int i = a;i >= b;i--)
using namespace std;
const int N = 512;
int r,c,m;
bool a[N][N];
bitset<512> dp[N],temp[N],grid[N];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//    ifstream cin ("nautilus.inp");
    cin >> r >> c >> m;
    rep(i,0,r-1)
    {
        rep(j,0,c-1)
        {
            char k;
            cin >> k;
            if(k == '.')
            {
                grid[i][c - j - 1] = 1;
                dp[i][c - j - 1] = 1;
            }

        }
    }
    rep(_,1,m)
    {
        char k;
        cin >> k;
        switch(k)
        {
        case 'N':
            {
                rep(i,1,r-1)
                    dp[i-1] = (dp[i] & grid[i-1]);
                dp[r-1].reset();
                break;
            }
        case 'E' :
            {
                rep(i,0,r-1)
                {
                    dp[i] >>= 1;
                    dp[i] &= grid[i];
                }

                break;
            }
        case 'S':
            {
                repd(i,r-1,1)
                    dp[i] = (dp[i-1] & grid[i]);
                dp[0].reset();
                break;
            }
        case 'W':
            {
                rep(i,0,r-1)
                {
                    dp[i] <<= 1;
                    dp[i] &= grid[i];
                }
                break;
            }
        default :
            {
                bitset<512> temp[N];
                rep(i,1,r-1) temp[i-1] |= dp[i];
                rep(i,0,r-1) temp[i] |= ((dp[i] >> 1) | (dp[i] << 1));
                repd(i,r-1,1) temp[i] |= dp[i-1];
                rep(i,0,r-1) temp[i] &= grid[i];
                rep(i,0,r-1) dp[i] = temp[i];
            }
        }
    }
    int ans = 0;
    rep(i,0,r-1)
        {
            rep(j,0,c-1) ans += dp[i][j];
        }
    cout << ans;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 3 ms 380 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 4 ms 376 KB Output is correct
17 Correct 3 ms 504 KB Output is correct
18 Correct 9 ms 376 KB Output is correct
19 Correct 4 ms 376 KB Output is correct
20 Correct 4 ms 248 KB Output is correct
21 Correct 4 ms 372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 3 ms 380 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 4 ms 376 KB Output is correct
17 Correct 3 ms 504 KB Output is correct
18 Correct 9 ms 376 KB Output is correct
19 Correct 4 ms 376 KB Output is correct
20 Correct 4 ms 248 KB Output is correct
21 Correct 4 ms 372 KB Output is correct
22 Correct 105 ms 780 KB Output is correct
23 Correct 100 ms 992 KB Output is correct
24 Correct 95 ms 740 KB Output is correct
25 Correct 93 ms 760 KB Output is correct
26 Correct 91 ms 632 KB Output is correct
27 Correct 151 ms 760 KB Output is correct
28 Correct 156 ms 760 KB Output is correct
29 Correct 158 ms 736 KB Output is correct
30 Correct 155 ms 736 KB Output is correct
31 Correct 152 ms 712 KB Output is correct
32 Correct 193 ms 632 KB Output is correct
33 Correct 197 ms 760 KB Output is correct
34 Correct 200 ms 736 KB Output is correct
35 Correct 193 ms 632 KB Output is correct
36 Correct 198 ms 712 KB Output is correct