Codeforce 735AOstap and Grasshopper DFS
来源:互联网 发布:美国pmi数据 编辑:程序博客网 时间:2024/06/18 16:58
跑一发DFS
#include <iostream> #include <cstdio>#include <cstdlib>#include <cmath>#include <algorithm>#include <climits>#include <cstring>#include <string>#include <set>#include <map>#include <queue>#include <stack>#include <vector>#include <list>#define rep(i,m,n) for(i=m;i<=n;i++)#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)const int inf_int = 2e9;const long long inf_ll = 2e18;#define inf_add 0x3f3f3f3f#define mod 1000000007#define vi vector<int>#define pb push_back#define mp make_pair#define fi first#define se second#define pi acos(-1.0)#define pii pair<int,int>#define Lson L, mid, rt<<1#define Rson mid+1, R, rt<<1|1const int maxn=5e2+10;using namespace std;typedef long long ll;typedef unsigned long long ull; inline int read(){int ra,fh;char rx;rx=getchar(),ra=0,fh=1;while((rx<'0'||rx>'9')&&rx!='-')rx=getchar();if(rx=='-')fh=-1,rx=getchar();while(rx>='0'&&rx<='9')ra*=10,ra+=rx-48,rx=getchar();return ra*fh;}//#pragma comment(linker, "/STACK:102400000,102400000")ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}void dfs(int cur);string a;int vis[1000];int n,k; int flag;int main(){ios::sync_with_stdio(false);cin >> n >> k;cin >> a;for(int i=0;i<a.size();i++)if(a[i]=='G'){dfs(i);if(flag==0)cout << "NO" <<endl;elsecout << "YES" <<endl;return 0;}return 0;} void dfs(int cur){if(flag)return ;if(a[cur]=='T'){flag =1;return ;}int next = cur+k;if(next>=0&&next<n&&a[next]!='#'&&vis[next]==0){vis[next]=1;dfs(next);vis[next]=0;}next = cur-k;if(next>=0&&next<n&&a[next]!='#'&&vis[next]==0){vis[next]=1;dfs(next);vis[next]=0;}}
0 0
- Codeforce 735AOstap and Grasshopper DFS
- CodeForces 735A - Ostap and Grasshopper(思维)
- codeforces - 735A-Ostap and Grasshopper
- 735 A. Ostap and Grasshopper codeforces
- codeforces 735 A Ostap and Grasshopper
- CodeForces 735A Ostap and Grasshopper
- codeforce C. Valera and Elections (DFS)
- Codeforce#394E. Dasha and Puzzle(dfs)
- A. Ostap and Grasshopper
- Codeforces735A Ostap and Grasshopper
- Little Artem and Grasshopper
- Grasshopper And the String
- Ostap and Grasshopper
- Grasshopper And the String
- Codeforces Round #382 (Div. 2) 735A - Ostap and Grasshopper
- codeforces 735 A. Ostap and Grasshopper (简单题)
- CodeForces 735 A.Ostap and Grasshopper(水~)
- Codeforces Round #382 (Div. 2) 735A Ostap and Grasshopper
- 奢华逆天的iFunk超极本新品即将诞生
- synchronized和lock的实现原理
- 七、Linux--共享内存
- 2016-12-03(两种处理JSON返回页面的方式、分页,ModelAndView和Model的区别,<C:forEach>注意)
- 笔记1之Qt4初步初步实践o
- Codeforce 735AOstap and Grasshopper DFS
- Linux System Commands(centos)
- Ubuntu下Apache开启Rewrite模块
- 八、Linux--高级IO
- 数组指针VS指向数组的指针
- 数据结构(1)
- 【数据结构与算法】【小知识】【word】 总结
- Linux下更好用的帮助命令—cheat
- Android设计模式之访问者模式 Visitor