Submission #496339

# Submission time Handle Problem Language Result Execution time Memory
496339 2021-12-21T06:05:48 Z Ziel Nautilus (BOI19_nautilus) C++17
29 / 100
4 ms 844 KB
/**
 * LES GREATEABLES BRO TEAM
**/

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
#define sz(x) (int)x.size()
const bool FLAG = false;
void setIO(const string &f = "");

#define int ll

void solve() {
    int r, c, m;
    cin >> r >> c >> m;
    vector<vector<char>> a(r + 1, vector<char>(c + 1));
    for (int i = 1; i <= r; i++) {
    	for (int j = 1; j <= c; j++) {
    		cin >> a[i][j];
    	}
    }
    string s;
    cin >> s;
    int ans = 0;
    auto in_frame = [r, c](int x, int y) -> bool {
    	return x >= 1 && x <= r && y >= 1 && y <= c;
    };
    set<pair<int, int>> st;
    for (int i = 1; i <= r; i++) {
    	for (int j = 1; j <= c; j++) {
    		if (a[i][j] == '#')
    			continue;
    		int ci = i, cj = j;
    		bool ok = true;
    		for (int k = 0; k < m; k++) {
    			if (s[k] == 'N') ci--;
    			if (s[k] == 'S') ci++;
    			if (s[k] == 'E') cj++;
    			if (s[k] == 'W') cj--;

    			if (in_frame(ci, cj) && a[ci][cj] == '.')
    				continue;
    			else {
    				ok = false;
    				break;
    			}
    		}
    		if (!ok)
    			continue;
    		st.insert({ci,cj});
    	}
    }
    cout << sz(st);
}

signed main() {
    setIO();
    
    int tt = 1;
    if (FLAG) {
    	cin >> tt;
    }
    while (tt--) {
    	solve();
    }
    
    return 0;
}

void setIO(const string &f) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    if (fopen((f + ".in").c_str(), "r")) {
        freopen((f + ".in").c_str(), "r", stdin);
        freopen((f + ".out").c_str(), "w", stdout);
    }
}

Compilation message

nautilus.cpp: In function 'void solve()':
nautilus.cpp:27:9: warning: unused variable 'ans' [-Wunused-variable]
   27 |     int ans = 0;
      |         ^~~
nautilus.cpp: In function 'void setIO(const string&)':
nautilus.cpp:77:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   77 |         freopen((f + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nautilus.cpp:78:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   78 |         freopen((f + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 716 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 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 716 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 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Incorrect 4 ms 844 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 716 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 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Incorrect 4 ms 844 KB Output isn't correct
8 Halted 0 ms 0 KB -