4452 模拟水题

2015-07-20 17:29:10 · 作者: · 浏览: 4
#include
  
   
#include
   
     #include
     
     using namespace std
     ; int abs
     (int a
     ) { return a
     >0
     ?a
     :(-a
     +1
     ); } int main() { int n
     ,i
     ,j
     ,s1
     ,t1
     ,s2
     ,t2
     ,m
     ; char first
     [5
     ],second
     [5
     ]; while(~scanf
     ("%d"
     ,&n
     ),n
     ) { scanf
     ("%s"
     ,first
     ); scanf
     ("%d%d"
     ,&s1
     ,&t1
     ); scanf
     ("%s%d%d"
     ,second
     ,&s2
     ,&t2
     ); scanf
     ("%d"
     ,&m
     ); int fx
     =1
     ,fy
     =1
     ,sx
     =n
     ,sy
     =n
     ; for(i
     =1
     ;i
     <=m
     ;i
     ++) { if(first
     [0
     ]=='W'
     ) { if(fy
     -1
     <s1
     ) { fy
     =s1
     -fy
     +2
     ; first
     [0
     ]='E'
     ; } else fy
     -=s1
     ; } else if(first
     [0
     ]=='E'
     ) { if(n
     -fy
     <s1
     ) { fy
     =2
     *n
     -s1
     -fy
     ; first
     [0
     ]='W'
     ; } else fy
     +=s1
     ; } else if(first
     [0
     ]=='N'
     ) { if(fx
     -1
     <s1
     ) { fx
     =s1
     -fx
     +2
     ; first
     [0
     ]='S'
     ; } else fx
     -=s1
     ; } else { if(n
     -fx
     <s1
     ) { fx
     =2
     *n
     -s1
     -fx
     ; first
     [0
     ]='N'
     ; } else fx
     +=s1
     ; } if(second
     [0
     ]=='W'
     ) { if(sy
     -1
     <s2
     ) { sy
     =s2
     -sy
     +2
     
;
second [0 ]='E' ; } else sy -=s2 ; } else if(second [0 ]=='E' ) { if(n -sy <s2 ) { sy =2 *n -s2 -sy ; second [0 ]='W' ; } else sy +=s2 ; } else if(second [0 ]=='N' ) { if(sx -1 <s2 ) { sx =s2 -sx +2 ; second [0 ]='S' ; } else sx -=s2 ; } else { if(n -sx <s2 ) { sx =2 *n -s2 -sx ; second [0 ]='N' ; } else sx +=s2 ; } if(fx ==sx &&fy ==sy ) { char p =first [0 ]; first [0 ]=second [0 ]; second [0 ]=p ; } else { if(i %t1 ==0 ) { if(first [0 ]=='W' ) first [0 ]='S' ; else if(first [0 ]=='E' ) first [0 ]='N' ; else if(first [0 ]=='N' ) first [0 ]='W' ; else first [0 ]='E' ; } if(i %t2 ==0 ) { if(second [0 ]=='W' ) second [0 ]='S' ; else if(second [0 ]=='E' ) second [0 ]='N' ; else if(second [0 ]=='N' ) second [0 ]='W' ; else second [0 ]='E' ; } } } printf ("%d %d\n" ,fx ,fy ); printf ("%d %d\n" ,sx ,sy ); } return 0 ; }