#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N =1e6+5;
int a[55][55],b[55][55];
int sum(int x){
	return (x*(x+1))/2;
}
int n,m,x,y; 
string s;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m>>y>>x;
	cin>>s;

	for(int i=0;i<s.size();i++){
		b[x][y]+=sum(i-a[x][y]);
		a[x][y]=i+1;
		if(s[i]=='N')x++;
		if(s[i]=='S')x--;
		if(s[i]=='W')y--;
		if(s[i]=='E')y++; 	
	}
	for(int i=n;i>=1;i--){
		for(int j=1;j<=n;j++){
			cout<<b[i][j]+sum(m-a[i][j])<<' ';
		}
		cout<<endl;
	}
	

	return 0;
}

0 comments

No comments so far...