Educational Codeforces Round 32 B. Buggy Robot(模拟)
来源:互联网 发布:手机房屋平面设计软件 编辑:程序博客网 时间:2024/06/05 18:34
题解:
这题还是比较水的,直接记录下四个方向执行了几次然后取相反方向的最小值乘2就是答案
代码:
#include<stdio.h>#include<string.h>#include<stdlib.h>#include<queue>#include<stack>#include<math.h>#include<vector>#include<map>#include<set>#include<stdlib.h>#include<cmath>#include<string>#include<algorithm>#include<iostream>using namespace std;#define lson k*2#define rson k*2+1#define M (t[k].l+t[k].r)/2#define ll long longint main(){ int n,i,j; int x=0,y=0,ans=0; char s[105]; int a[5]; memset(a,0,sizeof(a)); scanf("%d%s",&n,s); for(i=0;i<strlen(s);i++) { switch(s[i]) { case 'L':a[0]++;break; case 'R':a[1]++;break; case 'U':a[2]++;break; case 'D':a[3]++;break; } } if(a[0]!=0&&a[1]!=0) { ans+=min(a[0],a[1])*2; } if(a[2]!=0&&a[3]!=0) { ans+=min(a[2],a[3])*2; } printf("%d\n",ans);return 0;}
阅读全文
0 0
- Educational Codeforces Round 32 B. Buggy Robot(模拟)
- Codeforces 888B Buggy Robot (模拟)
- Educational Codeforces Round 6 (B)模拟
- Educational Codeforces Round 7(B)模拟
- Educational Codeforces Round 11(B)模拟
- CodeForces 888B Buggy Robot
- codeforces 893B. Buggy Robot
- Codeforces - Educational Codeforces Round 14B - s-palindrome(模拟)
- Educational Codeforces Round 7-B. The Time(模拟)
- Educational Codeforces Round 12(B)暴力模拟
- Codeforces-Educational Codeforces Round 32-(A,B,C,D)
- B. Buggy Robot
- Educational Codeforces Round 32 C. K-Dominant Character(模拟)
- Educational Codeforces Round 32 A B C
- Educational Codeforces Round 10(A)模拟
- Educational Codeforces Round 1(B)
- Educational Codeforces Round 5(B)贪心
- Educational Codeforces Round 30(A+B)
- 独轮车 推车的人脑子绕不过弯来 导致我写了好久
- mac下安装tomcat并配置Myeclipse过程
- Educational Codeforces Round 32 A. Local Extrema(模拟水题)
- PAT (Basic Level) Practise (中文)1037. 在霍格沃茨找零钱(20)
- win32 sdk下调用webbrowser控件
- Educational Codeforces Round 32 B. Buggy Robot(模拟)
- nginx 从入门到实践 -基础篇(2)
- SpringMVC(2)-- 常用注解类
- 软件工程(C编码实践篇)学习总结
- Educational Codeforces Round 32 C. K-Dominant Character(模拟)
- Maven工程的SpringMVC结构的Web程序
- 17.11.9日报
- C语言03
- idea java web开发遇到的问题