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 到每个点的最短路即可. ...
随机推荐
- 2-3 Flutter开发环境与iOS开发环境设置(Mac)
Mac下环境搭建 先不看了 都是Mac下的环境搭建
- 数据库中rs("ABC")与rs.Fields("ABC").value的差别(Rs是RecordSet对象)
透过RecordSet取得数据的时候我们要将数据显示出来时,假设字段名称是ABCABCX = rs("ABC")对于RecordSet来说....是把ABC这个[Fileds对象] ...
- shell初级-----构建基本脚本
使用多个命令 如果想要多个命令同时运行,可以把它们放在一行,用分号隔开. date;who 创建shell脚本文件 创建shell脚本时,必须在文件第一行指定要使用的shell #!/bin/bash ...
- cf769D(枚举&位或运算)
题目链接:http://codeforces.com/problemset/problem/769/D 题意:求给出的 n 个数中有多少对数字的二进制形式恰好有 k 位不同 思路:两个数a, b的二进 ...
- [转]PBFT 算法详解
https://www.cnblogs.com/mafeng/p/8405375.html
- CF961G Partitions(第二类斯特林数)
传送门 对于每一个元素,我们只要能求出它的出现次数\(sum\),那么每个元素的贡献都是一样的,最终的答案为\(sum\times \sum_{i=1}^n w_i\) 那么分别讨论 如果这个元素自己 ...
- git配置命令
一.Git安装及密钥的生成 1.下载Git软件:http://msysgit.github.io/ 2.桌面右键 Git Bash Here 打开git命令行: 3.ssh-keygen -t rsa ...
- JDBC连接数据以及详细的ResultSet结果集解释
一.数据库连接 (前面为jdbc的其他参数,文章下部分为ResultSet详解) ResultSet rs = st.executeQuery(sqlStr) 1. java的sql框架支持多种数据库 ...
- MySQL注释符号
今天在执行mysql语句时很奇怪为什么没有执行,查询后发现“-- ”是mysql的注释符号,不会执行的 mysql注释符有三种: 1.#... 2."-- ",注意--后面有一个 ...
- Eclipse中各图标含义
Eclipse中定义很多小图标,在平时的开发工作中,熟悉这些小图标还是很有意义的.那具体意义大家又知道多少呢? 首先,通过在搜索“eclipse icon meaning”,找到了一个比较有用的链接, ...