📄 1835.txt
字号:
#include"stdio.h"
struct point
{
int x, y, z;
};
inline point cross( point &a, point &b )
{
point c;
c.x = a.y*b.z - b.y*a.z;
c.y = a.z*b.x - b.z*a.x;
c.z = a.x*b.y - b.x*a.y;
return c;
}
inline void back( point &p )
{
p.x = -p.x;
p.y = -p.y;
p.z = -p.z;
}
void charge( point &up, point &towards, char c )
{
point t;
switch( c )
{
case 'f': break;
case 'l': towards = cross( up, towards); break;
case 'r': towards = cross( towards, up); break;
case 'b': back( towards ); break;
case 'u': t = towards; towards = up; up = t; back( up ); break;
case 'd': t = up; up = towards; towards = t; back( towards ); break;
}
return;
}
point normal[] = { {1,0,0}, {0,-1,0}, {0,0,1}, {-1,0,0}, {0,1,0}, {0,0,-1} };
int main()
{
int cas, n, x, i;
char w[10];
point up, towards;
__int64 xx,yy,zz;
scanf( "%d", &cas );
while( cas-- )
{
xx = yy = zz = 0;
up.z = 1, up.x = up.y = 0;
towards.x = 1, towards.y = towards.z = 0;
scanf( "%d", &n );
while(n--)
{
scanf( "%s %d", w, &x );
charge( up, towards, w[0] );
xx += x * towards.x;
yy += x * towards.y;
zz += x * towards.z;
}
for( i=0; i<6; i++ )
if( towards.x == normal[i].x && towards.y == normal[i].y && towards.z == normal[i].z )
break;
printf( "%I64d %I64d %I64d %d\n", xx, -yy, zz, i );
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -