답안 #889759

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
889759 2023-12-20T06:56:10 Z vjudge1 Nautilus (BOI19_nautilus) C++17
0 / 100
4 ms 860 KB
//#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")
//#pragma GCC target( "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define len(x) (int)x.size()
#define ull unsigned long long
#define F first
#define S second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define int long long
#define ld long double
#define pii pair<int,int>
#define mii map<int,int>

using namespace std;
using namespace __gnu_pbds;
using ll = long long;

const int N = 2e5 + 5;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const ll inf = 1e9;
int n,m,k;
string s,a[505];
set <pii> st;

pii go (int x, int y){
	for (int i=0;i<k;i++){
		if (s[i] == 'W'){
			y--;
			if (y < 0) return {-1, -1};
		}
		else if (s[i]=='N'){
			x++;
			if (x >= n) return {-1, -1};
		}
		else if (s[i]=='E'){
			y++;
			if (y >= m) return {-1, -1};
		}
		else{
			x--;
			if (x < 0) return {-1, -1};
		}
		if (a[x][y]=='#') return {-1, -1};
	}
	return {x, y};
}

signed main(){
	// freopen("txt.in", "r", stdin);
	// freopen("txt.out", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m >> k;
	for (int i=0;i<n;i++){
		cin >> a[i];
	}
	cin >> s;
	for (int i=0;i<n;i++){
		for (int j=0;j<m;j++){
			if (a[i][j]=='#') continue;
			pii res = go(i, j);
			if (res.F!=-1){
				st.insert(res);
			}
		}
	}
	cout << len(st);
}

//order_of_key(k): Number of items strictly smaller than k .
//find_by_order(k): K-th element in a set (counting from zero).

//sum of squares n*(n+1)*(2n+1)/6
//sum of cubes [n*(n+1)/2]^2
//sum of squares for odds n*(4*n*n-1)/3
//sum of cubes for odds n*n*(2*n*n-1)

//a/b%mod = a*(b^(m-2)%mod)
//(a>>x)&1 == 0
//a^b = (a+b)-2(a&b)

//srand(time(0))-always changing
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 860 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 860 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 860 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -