codeforecs Gym 100286B Blind Walk
交互式程序,要用到一个函数fflush,它的作用是对标准输出流的清理,对stdout来说是及时地打印数据到屏幕上,一个事实:标准输出是以『行』为单位进行的,也即碰到\n才打印数据到屏幕。这就可能造成延时。在Windows平台上是看不出来的,它被改成及时生效了。而fflush对stdin的作用是清除冗余输入。
#include<cstdio> const int maxn = ; //要AC
const int maxlen = ;
bool vis[maxn][maxn];
char dir[][maxlen] = {"NORTH","EAST","SOUTH","WEST"};
char done[] = "DONE"; int dx[] = {,,,-} , dy[] = {,,-,};
char response[maxlen]; bool Move(int d)
{
puts(dir[d]);
fflush(stdout);
gets(response);
return *response == 'E';
} void dfs(int x,int y)
{
vis[x][y] = true;
for(int i = ; i < ; i++) {
int nx = x + dx[i], ny = y + dy[i];
if(!vis[nx][ny] && Move(i)) dfs(nx,ny),Move((i+)%);
else vis[nx][ny] = true;
}
} int main()
{
int x = , y = ;
dfs(x,y);
puts(done);
fflush(stdout);
return ;
}
codeforecs Gym 100286B Blind Walk的更多相关文章
- Codeforces Gym 100286B Blind Walk DFS
Problem B. Blind WalkTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/cont ...
- ACM: Gym 101047E Escape from Ayutthaya - BFS
Gym 101047E Escape from Ayutthaya Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I6 ...
- Codeforces Gym 100803C Shopping 贪心
Shopping 题目连接: http://codeforces.com/gym/100803/attachments Description Your friend will enjoy shopp ...
- On the way to the park Gym - 101147I 几何
http://codeforces.com/gym/101147/problem/I I. On the way to the park time limit per test 5 seconds m ...
- python os.walk()
os.walk()返回三个参数:os.walk(dirpath,dirnames,filenames) for dirpath,dirnames,filenames in os.walk(): 返回d ...
- ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力
Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS Memory Limit:65536KB 64bit IO Fo ...
- ACM: Gym 101047K Training with Phuket's larvae - 思维题
Gym 101047K Training with Phuket's larvae Time Limit:2000MS Memory Limit:65536KB 64bit IO F ...
- ACM: Gym 101047B Renzo and the palindromic decoration - 手速题
Gym 101047B Renzo and the palindromic decoration Time Limit:2000MS Memory Limit:65536KB 64 ...
- LYDSY模拟赛day1 Walk
/* 依旧考虑新增 2^20 个点. i 只需要向 i 去掉某一位的 1 的点连边. 这样一来图的边数就被压缩到了 20 · 2^20 + 2n + m,然后 BFS 求出 1 到每个点的最短路即可. ...
随机推荐
- spring-eureka 源码解读----作为集群的eureka怎么样实现不做二次传播
在平时工作中,eureka作为一个集群时候,我们会配置多个peer ,假设当前有服务器eureka-A,eureka-B,eureka-C. 如果Eureka A的peer指向了B, B的peer指向 ...
- 洛谷P2875 [USACO07FEB]牛的词汇The Cow Lexicon
P2875 [USACO07FEB]牛的词汇The Cow Lexicon 题目描述 Few know that the cows have their own dictionary with W ( ...
- C 语言实例 - 循环输出26个字母
C 语言实例 - 循环输出26个字母 循环输出 个字母. 实例 #include <stdio.h> int main() { char c; for(c = 'A'; c <= ' ...
- 字符串前面u,r,b
u :代表是对字符串进行unicode编码. 一般英文字符在使用各种编码下, 基本都可以正常解析, 所以一般不带u:py3当对字符串进行操作的时候,默认使用Unicode编码 r/R:非转义的原始字符 ...
- 出现提示ERROR 1289 The 'InnoDB' feature is disabled; you need MySQL built with 'InnoDB' to have IT working
关闭mysql数据库 在mysql的安装目录中找到my.ini文件找到skip-innodb,在前面加上#号保存,重启mysql服务 OK.
- JS 对象的操作方法
第一种: 变量名.style.属性: 第二种: 变量名.style[参数]
- CF914D Bash and a Tough Math Puzzle 线段树+gcd??奇怪而精妙
嗯~~,好题... 用线段树维护区间gcd,按如下法则递归:(记题目中猜测的那个数为x,改动次数为tot) 1.若子区间的gcd是x的倍数,不递归: 2.若子区间的gcd是x的倍数,且没有递归到叶子结 ...
- JavaScript读取文本,并渲染在html
html <pre id="myText" style="word-wrap: break-word; white-space: pre-wrap; white-s ...
- js弹框怎么获得父页面的元素
js获取父页面的元素可以用$(window.parent.document).find("#customer_id").val();这里的customer_id表示父页面某一个元素 ...
- 【手撸一个ORM】第九步、orm默认配置类 MyDbConfiguration,一次配置,简化实例化流程
这个实现比较简单,事实上可配置的项目很多,如有需要,请读者自行扩展 using System; namespace MyOrm { public class MyDbConfiguration { p ...