제출 #1157559

#제출 시각아이디문제언어결과실행 시간메모리
1157559kiethm07Nautilus (BOI19_nautilus)C++20
100 / 100
236 ms748 KiB
#include <bits/stdc++.h>

#define pii pair<int,int>
#define iii pair<int,pii>
#define fi first
#define se second

#define vi vector<int>
#define all(x) x.begin(),x.end()
#define compact(x) x.erase(unique(all(x)),x.end())

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const int inf = 1e9 + 7;
const ld eps = 1e-8;
const double pi = acos(-1);
const int N = 500;
const int M = 500;

bitset<N * N> west, east, north, south, valid, cur;
int n,m,k;
int id = 0;
string s;

bitset<N * N> moveWest(bitset<N * N>& cur){
    return (cur >> 1) & west & valid;
}

bitset<N * N> moveEast(bitset<N * N>& cur){
    return (cur << 1) & east & valid;
}

bitset<N * N> moveNorth(bitset<N * N>& cur){
    return (cur >> m) & north & valid;
}

bitset<N * N> moveSouth(bitset<N * N>& cur){
    return (cur << m) & south & valid;
}

bitset<N * N> moveAll(bitset<N * N>& cur){
    bitset<N * N> ans;
    ans |= moveEast(cur);
    ans |= moveWest(cur);
    ans |= moveNorth(cur);
    ans |= moveSouth(cur);
    return ans;
}

void print(bitset<N * N> f){
    int id = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++) cout << f[id++];
        cout << "\n";
    }
    cout << "\n";
}

int main(){
    cin.tie(0) -> sync_with_stdio(0);
    #define TEXT "nautilus"
    if (fopen(TEXT".inp","r")){
        freopen(TEXT".inp","r",stdin);
//        freopen(TEXT".out","w",stdout);
    }
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            char c;
            cin >> c;
            if (c == '.') valid[id] = 1;
            if (j < m - 1) west[id] = 1;
            if (j > 0) east[id] = 1;
            if (i < n - 1) north[id] = 1;
            if (i > 0) south[id] = 1;
            id++;
        }
    }
    cur = valid;
    cin >> s;
    for (int i = 0; i < s.size(); i++){
        if (s[i] == 'W') cur = moveWest(cur);
        if (s[i] == 'E') cur = moveEast(cur);
        if (s[i] == 'N') cur = moveNorth(cur);
        if (s[i] == 'S') cur = moveSouth(cur);
        if (s[i] == '?') cur = moveAll(cur);
    }
    cout << cur.count() << "\n";
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

nautilus.cpp: In function 'int main()':
nautilus.cpp:67:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |         freopen(TEXT".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...