トップ 差分 一覧 Farm ソース 検索 ヘルプ PDF RSS ログイン

2006ra4.cpp

#include <iostream>
using namespace std;
#define SIZE 21
bool map[SIZE][SIZE];

void clear()
{
	for(int j=0; j<SIZE; j++){
		for(int i=0; i<SIZE; i++){
			map[i][j]=false;
		}
	}
}

main()
{
	int n,m,x,y,tx,ty,move;
	char d;
	while(1){
		cin >> n;
		if(n==0) break;
		clear();
		for(int i=0; i<n; i++){
			cin >> tx >> ty;
			map[tx][ty]=true;
		}
		cin >> m;
		x=y=10;
		for(int i=0; i<m; i++){
			cin >> d >> move;
			for(int j=0; j<move; j++){
				switch(d){
					case 'N':y++; break;
					case 'E':x++; break;
					case 'W':x--; break;
					case 'S':y--; break;
				}
				if(map[x][y]){
					map[x][y]=false;
					n--;
				}
			}
		}
		if(n>0){
			cout << "No" << endl;
		}else{
			cout << "Yes" << endl;
		}
	}
	return 0;
}