トップ 一覧 Farm 検索 ヘルプ 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;
 }