没学过计算机开始学做网站,qq邮箱在线登录网页版,酷站网官网,wordpress 通讯录插件资源限制
内存限制#xff1a;256.0MB C/C时间限制#xff1a;1.0s Java时间限制#xff1a;3.0s Python时间限制#xff1a;5.0s
问题描述 足球赛上#xff0c;只见Q神如闪电般的速度带球时而左#xff0c;时而右#xff0c;时而前#xff0c;时而后#xff…资源限制
内存限制256.0MB C/C时间限制1.0s Java时间限制3.0s Python时间限制5.0s
问题描述 足球赛上只见Q神如闪电般的速度带球时而左时而右时而前时而后时而上时而下……等等有什么奇怪的东西混进去了假设Q神力量可以突破地心引力他在一个三维空间里面可以沿着直角坐标系的坐标轴方向前进。告诉你他的每一次转的方向以及前进的距离请你回答他最后在哪个位置面朝那一个方向。假设他一开始在000面朝x轴的正方向。
输入格式 多组输入数据。 每组第一行是一个整数n。接下来n行每行一个字符表示方向接着一个整数表示前进距离。其中fforward表示继续前进方向不变bback表示向后转lleft表示向左转rright表示像右转uup表示向上d表示向下。如图示。 输出格式 对于每一组数据输出Q神的坐标和他的朝向。其中左手系的x正方向、y正方向、z正方向分别位0、1、2对应的负方向分别为3、4、5. 样例输入
6
l 10
r 11
u 12
d 13
f 14
b 15样例输出
23 -10 12 3数据规模和约定 数据组数不超过10组n《200 每次移动距离不超过100
#includeiostream
using namespace std;
int next_face(int face,int foot,char orient){if(face0){if(foot5){if(orientf){face0;}else if(orientb){face3;}else if(orientl){face4;}else if(orientr){face1;}else if(orientu){face2;foot0;}else if(orientd){face5;foot3;}}if(foot1){if(orientf){face0;}else if(orientb){face3;}else if(orientl){face5;}else if(orientr){face2;}else if(orientu){face4;foot0;}else if(orientd){face1;foot3;}}if(foot2){if(orientf){face0;}else if(orientb){face3;}else if(orientl){face1;}else if(orientr){face4;}else if(orientu){face5;foot0;}else if(orientd){face2;foot3;}}if(foot4){if(orientf){face0;}else if(orientb){face3;}else if(orientl){face2;}else if(orientr){face5;}else if(orientu){face1;foot0;}else if(orientd){face4;foot3;}}}else if(face1){if(foot5){if(orientf){face1;}else if(orientb){face4;}else if(orientl){face0;}else if(orientr){face3;}else if(orientu){face2;foot1;}else if(orientd){face5;foot4;}}if(foot3){if(orientf){face1;}else if(orientb){face4;}else if(orientl){face5;}else if(orientr){face2;}else if(orientu){face0;foot1;}else if(orientd){face3;foot4;}}if(foot2){if(orientf){face1;}else if(orientb){face4;}else if(orientl){face3;}else if(orientr){face0;}else if(orientu){face5;foot1;}else if(orientd){face2;foot4;}}if(foot0){if(orientf){face1;}else if(orientb){face4;}else if(orientl){face2;}else if(orientr){face5;}else if(orientu){face3;foot1;}else if(orientd){face0;foot4;}}}else if(face2){if(foot4){if(orientf){face2;}else if(orientb){face5;}else if(orientl){face3;}else if(orientr){face0;}else if(orientu){face1;foot2;}else if(orientd){face4;foot5;}}if(foot3){if(orientf){face2;}else if(orientb){face5;}else if(orientl){face1;}else if(orientr){face4;}else if(orientu){face0;foot2;}else if(orientd){face3;foot5;}}if(foot1){if(orientf){face2;}else if(orientb){face5;}else if(orientl){face0;}else if(orientr){face3;}else if(orientu){face4;foot2;}else if(orientd){face1;foot5;}}if(foot0){if(orientf){face2;}else if(orientb){face5;}else if(orientl){face4;}else if(orientr){face1;}else if(orientu){face3;foot2;}else if(orientd){face0;foot5;}}}else if(face3){if(foot5){if(orientf){face3;}else if(orientb){face0;}else if(orientl){face1;}else if(orientr){face4;}else if(orientu){face2;foot3;}else if(orientd){face5;foot0;}}if(foot1){if(orientf){face3;}else if(orientb){face0;}else if(orientl){face2;}else if(orientr){face5;}else if(orientu){face4;foot3;}else if(orientd){face1;foot0;}}if(foot2){if(orientf){face3;}else if(orientb){face0;}else if(orientl){face4;}else if(orientr){face1;}else if(orientu){face5;foot3;}else if(orientd){face2;foot0;}}if(foot4){if(orientf){face3;}else if(orientb){face0;}else if(orientl){face5;}else if(orientr){face2;}else if(orientu){face1;foot3;}else if(orientd){face4;foot0;}}}else if(face4){if(foot5){if(orientf){face4;}else if(orientb){face1;}else if(orientl){face3;}else if(orientr){face0;}else if(orientu){face2;foot4;}else if(orientd){face5;foot1;}}if(foot3){if(orientf){face4;}else if(orientb){face1;}else if(orientl){face2;}else if(orientr){face5;}else if(orientu){face0;foot4;}else if(orientd){face3;foot1;}}if(foot2){if(orientf){face4;}else if(orientb){face1;}else if(orientl){face0;}else if(orientr){face3;}else if(orientu){face5;foot4;}else if(orientd){face2;foot1;}}if(foot0){if(orientf){face4;}else if(orientb){face1;}else if(orientl){face5;}else if(orientr){face2;}else if(orientu){face3;foot4;}else if(orientd){face0;foot1;}}}else if(face5){if(foot1){if(orientf){face5;}else if(orientb){face2;}else if(orientl){face3;}else if(orientr){face0;}else if(orientu){face4;foot5;}else if(orientd){face1;foot2;}}if(foot3){if(orientf){face5;}else if(orientb){face2;}else if(orientl){face4;}else if(orientr){face1;}else if(orientu){face0;foot5;}else if(orientd){face3;foot2;}}if(foot4){if(orientf){face5;}else if(orientb){face2;}else if(orientl){face0;}else if(orientr){face3;}else if(orientu){face1;foot5;}else if(orientd){face4;foot2;}}if(foot0){if(orientf){face5;}else if(orientb){face2;}else if(orientl){face1;}else if(orientr){face4;}else if(orientu){face3;foot5;}else if(orientd){face0;foot2;}}}
}
int main(){int n;while(cinn){int x0,y0,z0;//最开始时的坐标int face0;//脸的朝向 int foot5;//脚的站位 for(int i0;in;i){char orient;int num;cinorientnum;next_face(face,foot,orient);if(face0){xnum;}else if(face1){ynum;}else if(face2){znum;}else if(face3){x-num;}else if(face4){y-num;}else if(face5){z-num;}} coutx y z face endl;}return 0;
} 思路需要知道Q神的脸的朝向、脚的站位头指向脚的方向才能确定Q神的位置。已知脸的朝向可能有4个站位。
例如初始位置脸的朝向为0脚的站位为5