B. New Year and Buggy Bot

思路:使用全排列函数,{0,1,2,3}共24种情况.

#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3, "Ofast", "inline")
#define SIS std::ios::sync_with_stdio(false),std::cin.tie(nullptr);
#include "bits/stdc++.h"
#define ll long long
using namespace std;
char s[4] = {'0','1','2','3'};
char c[55][55];
void slove() {int n, m;int sx, sy, ex, ey;cin >> n >> m;for (int i = 1; i <= n; i++) {for (int j = 1; j <= m; j++) {cin >> c[i][j];if (c[i][j] == 'S') {sx = i;sy = j;}}}string cc;cin >> cc;int ans = 0;do{int x = sx;int y = sy;for (int i = 0; i < cc.size(); i++) {if (cc[i] == s[0]) x++;else if (cc[i] == s[1]) y--;else if (cc[i] == s[2]) x--;else if (cc[i] == s[3]) y++;if (c[x][y] == '#' || x<1 || y<1 || x>n || y>m) break;else if (c[x][y]=='E') {ans++;break;}}} while (next_permutation(s, s + 4));//全排列函数cout << ans << endl;
}
int main() {SISint t = 1;while (t--)slove();return 0;
}

Codeforces 908 B. New Year and Buggy Bot相关推荐

  1. 【Codeforces】908B New Year and Buggy Bot(暴力+全排列)

    http://codeforces.com/contest/908/problem/B 0 1 2 3 可以对应 上下左右.(具体哪个对应哪个,试过才知道) str 的 长度 为 100,0 1 2 ...

  2. B - New Year and Buggy Bot

    传送门 https://vjudge.net/contest/279162#problem/B 先做一个映射的排列一共24种,不算太多,手写可以,但是~~我懒啊,写一个递归函数将0,1,2,3做一个全 ...

  3. CodeForces Goodbye 2017

    传送门 A - New Year and Counting Cards •题意 有n张牌,正面有字母,反面有数字 其中元音字母$a,e,o,i,u$的另一面必须对应$0,2,4,6,8$的偶数 其他字 ...

  4. Codeforces 题目合集+分类+代码 【Updating...】【361 in total】

    961A - Tetris                                                模拟                                      ...

  5. Good Bye 2017

    太菜了啊,一不小心就goodbye rating了 A. New Year and Counting Cards time limit per test 1 second memory limit p ...

  6. Educational Codeforces Round 32

    http://codeforces.com/contest/888 A Local Extrema[水] [题意]:计算极值点个数 [分析]:除了第一个最后一个外,遇到极值点ans++,包括极大和极小 ...

  7. 打CodeForces时一款好用的vscode插件,如何使用 如何更好地使用

    目录 前言 插件名称 如何下载 如何使用 登录方法 如何比赛和提交 自测 提交 排名 如何更好地使用 模板的更改 方法一 修改template.cpp文件 方法二 设置默认模板文件 光标的定位 注意事 ...

  8. VSCODE codeforces 插件

    VSCODE codeforces 插件 选择插件 CodePal Codeforces Bot Codeforeces (没错,有个插件就叫这个名字) Catalyst.ICIE.acmX 最后 选 ...

  9. Educational Codeforces Round 103 (Rated for Div. 2)前四题

    Educational Codeforces Round 103 (Rated for Div. 2) 第二次被别人hack,悲 A - K-divisible Sum 题意 给定两个整数 n,kn, ...

最新文章

  1. PCL点云特征描述与提取(4)
  2. 最新发布 | 2018年度第八届吴文俊人工智能科学技术奖获奖名单公示
  3. 【NLP】fastText词向量与文本分类工具
  4. C/C++学习之路: 模板和异常
  5. jmeter自定义并发用户数图形插件介绍
  6. 定了!2020年,6种将死的编程语言!
  7. 解决eclipse刚启动卡死的问题~~~亲测有效~~
  8. java三元组的快速转置_矩阵压缩——三元组以及矩阵快速转置程序实现
  9. 查询各种物流运输信息
  10. allegro 16.6 空心焊盘的制作
  11. js 数组合并并且去重
  12. matlab实现Sobel边缘检测
  13. 分位数回归 Quantile Regression,python 代码
  14. 2022年上半年5月网络工程师试题及答案
  15. Python中一些少数人知晓且有趣的特性
  16. [转载] 晓说——第14期:揭秘战争秘闻 朝鲜战争62年祭(上)
  17. jsp免费虚拟空间 jhost邀请码
  18. On the burstiness of visual elements
  19. android项目中使用的服务器上,android 开发中使用okhttp上传文件到服务器
  20. android6.0屏蔽home键,android 禁用home键

热门文章

  1. 第三单元分支结构程序设计总结与感想
  2. hdu计算机学院大学生程序设计竞赛(2015’11)1003 玩骰子
  3. php正则匹配多个,15个超实用的php正则表达式
  4. 微信小程序页面跳转方式+跳转小程序(直接复制代码可用)
  5. [hive]hive优化
  6. np.random.seed()随机数种子
  7. 超实用篇之服务器日志查询定位
  8. 学历和能力对程序员哪个更重要
  9. MAYA2018中按到f或a摄像机失效解决办法
  10. 手把手带你开发企业级支付系统