Codeforces 908 B. New Year and Buggy Bot
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相关推荐
- 【Codeforces】908B New Year and Buggy Bot(暴力+全排列)
http://codeforces.com/contest/908/problem/B 0 1 2 3 可以对应 上下左右.(具体哪个对应哪个,试过才知道) str 的 长度 为 100,0 1 2 ...
- B - New Year and Buggy Bot
传送门 https://vjudge.net/contest/279162#problem/B 先做一个映射的排列一共24种,不算太多,手写可以,但是~~我懒啊,写一个递归函数将0,1,2,3做一个全 ...
- CodeForces Goodbye 2017
传送门 A - New Year and Counting Cards •题意 有n张牌,正面有字母,反面有数字 其中元音字母$a,e,o,i,u$的另一面必须对应$0,2,4,6,8$的偶数 其他字 ...
- Codeforces 题目合集+分类+代码 【Updating...】【361 in total】
961A - Tetris 模拟 ...
- Good Bye 2017
太菜了啊,一不小心就goodbye rating了 A. New Year and Counting Cards time limit per test 1 second memory limit p ...
- Educational Codeforces Round 32
http://codeforces.com/contest/888 A Local Extrema[水] [题意]:计算极值点个数 [分析]:除了第一个最后一个外,遇到极值点ans++,包括极大和极小 ...
- 打CodeForces时一款好用的vscode插件,如何使用 如何更好地使用
目录 前言 插件名称 如何下载 如何使用 登录方法 如何比赛和提交 自测 提交 排名 如何更好地使用 模板的更改 方法一 修改template.cpp文件 方法二 设置默认模板文件 光标的定位 注意事 ...
- VSCODE codeforces 插件
VSCODE codeforces 插件 选择插件 CodePal Codeforces Bot Codeforeces (没错,有个插件就叫这个名字) Catalyst.ICIE.acmX 最后 选 ...
- Educational Codeforces Round 103 (Rated for Div. 2)前四题
Educational Codeforces Round 103 (Rated for Div. 2) 第二次被别人hack,悲 A - K-divisible Sum 题意 给定两个整数 n,kn, ...
最新文章
- PCL点云特征描述与提取(4)
- 最新发布 | 2018年度第八届吴文俊人工智能科学技术奖获奖名单公示
- 【NLP】fastText词向量与文本分类工具
- C/C++学习之路: 模板和异常
- jmeter自定义并发用户数图形插件介绍
- 定了!2020年,6种将死的编程语言!
- 解决eclipse刚启动卡死的问题~~~亲测有效~~
- java三元组的快速转置_矩阵压缩——三元组以及矩阵快速转置程序实现
- 查询各种物流运输信息
- allegro 16.6 空心焊盘的制作
- js 数组合并并且去重
- matlab实现Sobel边缘检测
- 分位数回归 Quantile Regression,python 代码
- 2022年上半年5月网络工程师试题及答案
- Python中一些少数人知晓且有趣的特性
- [转载] 晓说——第14期:揭秘战争秘闻 朝鲜战争62年祭(上)
- jsp免费虚拟空间 jhost邀请码
- On the burstiness of visual elements
- android项目中使用的服务器上,android 开发中使用okhttp上传文件到服务器
- android6.0屏蔽home键,android 禁用home键