답안 #328827

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
328827 2020-11-18T07:11:49 Z egas Nautilus (BOI19_nautilus) C++14
66 / 100
22 ms 3308 KB
#include <bits/stdc++.h>

using namespace std;

int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    int r;

    cin >> r;

    int c;

    cin >> c;

    int m;

    cin >> m;

    vector<string> grid;

    for(int i = 0 ; i < r ; i++) {

        string temp;

        cin >> temp;

        grid.push_back(temp);

    }

    string path;

    cin >> path;

    bool canVisit[101][101][101];

    memset(canVisit,0,sizeof canVisit);

    int res=0;

    for(int i = 0 ; i < r ; i++) {

        for(int j = 0 ; j < c ; j++) {

            if(grid[i][j]=='.') {

                canVisit[i][j][0]=true;

            }

        }

    }

    for(int k=0; k<path.length(); k++) {

        if(path[k]=='S') {

            for(int i = 0 ; i < r ; i++) {

                for(int j = 0 ; j < c ; j++) {

                    if(i-1>=0 and canVisit[i-1][j][k] and grid[i][j]=='.') {

                        canVisit[i][j][k+1]=1;

                    }

                }

            }

        } else if(path[k]=='N') {

            for(int i = 0 ; i < r ; i++) {

                for(int j = 0 ; j < c ; j++) {

                    if(i+1<r and canVisit[i+1][j][k] and grid[i][j]=='.') {

                        canVisit[i][j][k+1]=1;

                    }

                }

            }

        } else if(path[k]=='E') {

            for(int i = 0 ; i < r ; i++) {

                for(int j = 0 ; j < c ; j++) {

                    if(j-1>=0 and canVisit[i][j-1][k] and grid[i][j]=='.') {

                        canVisit[i][j][k+1]=1;

                    }

                }

            }

        } else if(path[k]=='W') {

            for(int i = 0 ; i < r ; i++) {

                for(int j = 0 ; j < c ; j++) {

                    if(j+1<c and canVisit[i][j+1][k] and grid[i][j]=='.') {

                        canVisit[i][j][k+1]=1;

                    }

                }

            }

        } else {

            for(int i = 0 ; i < r ; i++) {

                for(int j = 0 ; j < c ; j++) {

                    if(i-1>=0 and canVisit[i-1][j][k] and grid[i][j]=='.') {

                        canVisit[i][j][k+1]=1;

                    }

                    if(i+1<r and canVisit[i+1][j][k] and grid[i][j]=='.') {

                        canVisit[i][j][k+1]=1;

                    }

                    if(j+1<c and canVisit[i][j+1][k] and grid[i][j]=='.') {

                        canVisit[i][j][k+1]=1;

                    }

                    if(j-1>=0 and canVisit[i][j-1][k] and grid[i][j]=='.') {

                        canVisit[i][j][k+1]=1;

                    }

                }

            }

        }

    }

    for(int i = 0 ; i < r ; i++) {

        for(int j = 0 ; j < c ; j++) {

            res+=canVisit[i][j][path.length()];

        }

    }

    cout << res << '\n';

    return 0;

}

Compilation message

nautilus.cpp: In function 'int32_t main()':
nautilus.cpp:59:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for(int k=0; k<path.length(); k++) {
      |                  ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1388 KB Output is correct
2 Correct 4 ms 1388 KB Output is correct
3 Correct 3 ms 1388 KB Output is correct
4 Correct 3 ms 1388 KB Output is correct
5 Correct 3 ms 1388 KB Output is correct
6 Correct 3 ms 1388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1388 KB Output is correct
2 Correct 4 ms 1388 KB Output is correct
3 Correct 3 ms 1388 KB Output is correct
4 Correct 3 ms 1388 KB Output is correct
5 Correct 3 ms 1388 KB Output is correct
6 Correct 3 ms 1388 KB Output is correct
7 Correct 7 ms 1388 KB Output is correct
8 Correct 8 ms 1388 KB Output is correct
9 Correct 6 ms 1388 KB Output is correct
10 Correct 5 ms 1388 KB Output is correct
11 Correct 5 ms 1388 KB Output is correct
12 Correct 11 ms 1388 KB Output is correct
13 Correct 17 ms 1388 KB Output is correct
14 Correct 20 ms 1408 KB Output is correct
15 Correct 8 ms 1388 KB Output is correct
16 Correct 7 ms 1388 KB Output is correct
17 Correct 14 ms 1388 KB Output is correct
18 Correct 21 ms 1388 KB Output is correct
19 Correct 22 ms 1408 KB Output is correct
20 Correct 12 ms 1388 KB Output is correct
21 Correct 8 ms 1388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1388 KB Output is correct
2 Correct 4 ms 1388 KB Output is correct
3 Correct 3 ms 1388 KB Output is correct
4 Correct 3 ms 1388 KB Output is correct
5 Correct 3 ms 1388 KB Output is correct
6 Correct 3 ms 1388 KB Output is correct
7 Correct 7 ms 1388 KB Output is correct
8 Correct 8 ms 1388 KB Output is correct
9 Correct 6 ms 1388 KB Output is correct
10 Correct 5 ms 1388 KB Output is correct
11 Correct 5 ms 1388 KB Output is correct
12 Correct 11 ms 1388 KB Output is correct
13 Correct 17 ms 1388 KB Output is correct
14 Correct 20 ms 1408 KB Output is correct
15 Correct 8 ms 1388 KB Output is correct
16 Correct 7 ms 1388 KB Output is correct
17 Correct 14 ms 1388 KB Output is correct
18 Correct 21 ms 1388 KB Output is correct
19 Correct 22 ms 1408 KB Output is correct
20 Correct 12 ms 1388 KB Output is correct
21 Correct 8 ms 1388 KB Output is correct
22 Runtime error 4 ms 3308 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Halted 0 ms 0 KB -