AC代码
#include<bits/stdc++.h> using namespace std; int main() { //freopen("city.in", "r", stdin); //freopen("city.out", "w", stdout); int xyuan,yyuan,maxx,maxy,num,b; char a; cin>>maxx>>maxy>>num; cin>>xyuan>>yyuan; for(int i=0;i<=num-1;i++) { cin>>a>>b; { if(a=='r') { yyuan+=b; } if(a=='l') { yyuan-=b; } if(a=='d') { xyuan-=b; } if(a=='u') { xyuan+=b; } { if(yyuan>=maxx) yyuan=maxx; if(yyuan<=0) yyuan=0; if(xyuan>=maxy) xyuan=maxy; if(xyuan<=0) xyuan=0; } } } cout<<xyuan<<" "<<yyuan; //fclose(stdin); //fclose(stdout); }