답안 #496276

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
496276 2021-12-21T04:41:33 Z kingline Nautilus (BOI19_nautilus) C++17
29 / 100
3 ms 332 KB
/*#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#include <bits/stdc++.h>
#define file(data) freopen(data".in", "r", stdin); freopen(data".out", "w", stdout);
#define pb push_back
#define all(data) data.begin(), data.end()
#define endl '\n'
#define ll long long
//#define int long long
#define pii pair < int, int >

using namespace std;

const int N = 2e5 + 5;

int n, m, k, use, used[505][505];
char c[505][505];
bool can[505][505];
string s;

void check(int x, int y) {
    bool ok = 1;
    for(int i = 0; i < s.size(); i++) {
        bool cn = 0;
        if(s[i] == 'S' && x + 1 <= n && c[x + 1][y] == '.') {
            x++;
            cn = 1;
        }
        if(s[i] == 'N' && x - 1 > 0 && c[x - 1][y] == '.') {
            x--;
            cn = 1;
        }
        if(s[i] == 'W' && y - 1 > 0 && c[x][y - 1] == '.') {
            y--;
            cn = 1;
        }
        if(s[i] == 'E' && y + 1 > 0 && c[x][y + 1] == '.') {
            y++;
            cn = 1;
        }
        if(!cn) {
            ok = 0;
            break;
        }
    }
    if(ok) can[x][y] = 1;
}

main() {
    //file("pieaters");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            cin >> c[i][j];
        }
    }
    cin >> s;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if(c[i][j] == '.') {
                check(i, j);
            }
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if(can[i][j]) {
                ans++;
            }
        }
    }
    cout << ans;
}






Compilation message

nautilus.cpp: In function 'void check(int, int)':
nautilus.cpp:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i = 0; i < s.size(); i++) {
      |                    ~~^~~~~~~~~~
nautilus.cpp: At global scope:
nautilus.cpp:52:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   52 | main() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Incorrect 1 ms 332 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Incorrect 1 ms 332 KB Output isn't correct
8 Halted 0 ms 0 KB -