【Good Bye 2017 B】 New Year and Buggy Bot
2017-12-30 10:51
381 查看
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
枚举一下全排列。看看有多少种可以到达终点即可。
【代码】
#include <bits/stdc++.h> using namespace std; const int dx[4] = {0,0,1,-1}; const int dy[4] = {1,-1,0,0}; const int N = 50; vector <int> v; char s[N+10][N+10]; int n,m; pair <int,int> qidian,zhongdian; string S; pair <int,int> findqidian(){ for (int i = 1;i <= n;i++) for (int j = 1;j <= m;j++) if (s[i][j]=='S') return make_pair(i,j); return make_pair(-1,-1); } pair <int,int> findzhongdian(){ for (int i = 1;i <= n;i++) for (int j = 1;j <= m;j++) if (s[i][j]=='E') return make_pair(i,j); return make_pair(-1,-1); } bool ok(){ int x = qidian.first,y = qidian.second; int len = S.size(); for (int i =0;i < len;i++){ int idx = S[i]-'0'; idx = v[idx]; x = x + dx[idx],y = y + dy[idx]; if (x>=1 && x <= n && y >=1 && y <=m){ if (x==zhongdian.first && y == zhongdian.second) return true; if (s[x][y]=='#') return false; continue; }else{ return false; } } return false; } int main(){ #ifdef LOCAL_DEFINE freopen("rush_in.txt", "r", stdin); #endif ios::sync_with_stdio(0),cin.tie(0); cin >> n >> m; for (int i = 1;i <= n;i++) cin >> (s[i]+1); cin >> S; for (int i = 0;i <= 3;i++) v.push_back(i); qidian = findqidian(); zhongdian = findzhongdian(); int cnt = 0; do{ if (ok()) cnt++; }while (next_permutation(v.begin(),v.end())); cout << cnt << endl; return 0; }
相关文章推荐
- Good Bye 2017 B - New Year and Buggy Bot
- Codeforces-Good Bye 2017 B. New Year and Buggy Bot(模拟)
- Codeforces Good Bye 2017 B - New Year and Buggy Bot
- Good Bye 2017-B. New Year and Buggy Bot
- codeforces。 goodbye 2017。 B. New Year and Buggy Bot
- 【Good Bye 2017 C】 New Year and Curling
- Good Bye 2017 E. New Year and Entity Enumeration
- Good Bye 2017 E. New Year and Entity Enumeration
- Good Bye 2017 A - New Year and Counting Cards
- Good Bye 2017-D. New Year and Arbitrary Arrangement
- Good Bye 2017 D.New Year and Arbitrary Arrangement - 数学
- Codeforces-Good Bye 2017 C. New Year and Curling(计算几何)
- Codeforces Good Bye 2017 F - New Year and Rainbow Roads
- Good Bye 2017 D - New Year and Arbitrary Arrangement
- Good Bye 2017 F-New Year and Rainbow Roads
- Codeforces Good Bye 2017 C. New Year and Curling(模拟水题)
- Codeforces Good Bye 2017 908F - New Year and Rainbow Roads 贪心+模拟
- Codeforces Good Bye 2017 D. New Year and Arbitrary Arrangement
- Good Bye 2017 D. New Year and Arbitrary Arrangement
- New Year and Buggy Bot