2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem K. KMC Attacks 交互题 暴力
Problem K. KMC Attacks
题目连接:
http://codeforces.com/gym/100714
Description
Warrant VI is a remote planet located in the Koprulu Sector. Warrant VI features a strange huge field,
which was discovered by the Kel-Morian Combine (KMC). The KMC is involved into a conflict with the
Scientific Community, which wishes to study the field, but the KMC intends to hold on to the significant
mineral wealth located there.
The field is represented by a rectangle of size N × M cells. All coordinates are positive integers. The left
upper corner is located at (1, 1) and the right bottom corner is at (N, M). The Scientific Community
have sent a T-280 unit to the field. You are one of the KMC members, your task is to find the unit
and destroy it. You have an orbital base equipped with a scanner at your disposal. You can examine
any single cell and if scan reveals the unit, a detachment is sent to destroy it. After every scan the unit
changes its location (i, j) by moving into one of four (three if the unit is in a border cell or two if it is in
a corner cell) adjacent cells. The unit has a tracking device. For every unit’s move you receive a signal:
‘U’ (for up, i decreases by one), ‘D’ (for down, i increases by one), ‘L’ (for left, j decreases by one), or ‘R’
(for right, j increases by one).
Time is running out so you are allowed to make not greater than 50000 scans to reveal the T-280 location.
Although the initial position of the unit is unknown, each its move provides you with information. You
are forbidden to scan cells, which definitely cannot hold the unit according to the gathered information.
Input
This is an interactive problem. Your program should first read a line with two integers N and M from
the standard input (where N is the height and M is the width of the field, 1 ≤ N, M ≤ 200). Then, for
every scan your program should print a corresponding request to the standard output (see below) and
read a reply from the standard input. Each reply is placed in a separate line and is either ’U’, ’D’, ’L’, ’R’
(meaning that you have missed and the unit has moved in the given direction) or ’DETECTED’ (meaning
that your last scan has revealed the unit’s position).
Output
For each scan print its coordinates i, j in a separate line (where i is the row number and j is the column
number). You have to flush the standard output after printing each request.
Sample Input
1 2
L
DETECTED
Sample Output
1 1
1 1
Hint
题意
交互题,在nm的矩阵,然后你需要找到一个东西。
每次你可以输入一个i,j位置,然后这个东西如果被抓到了,会返回delete,否则就会输出这个东西往哪儿走了。
题解:
暴力枚举这个东西的起点,然后判断现在的路径在哪儿,然后这样一直判断就好了。
注意,中途出界的点也得删去。
代码
#include <bits/stdc++.h>
#define rep(a,b,c) for(int (a)=(b);(a)<=(c);++(a))
#define drep(a,b,c) for(int (a)=(b);(a)>=(c);--(a))
#define pb push_back
#define mp make_pair
#define sf scanf
#define pf printf
#define two(x) (1<<(x))
#define clr(x,y) memset((x),(y),sizeof((x)))
#define dbg(x) cout << #x << "=" << x << endl;
const int mod = 1e9 + 7;
int mul(int x,int y){return 1LL*x*y%mod;}
int qpow(int x , int y){int res=1;while(y){if(y&1) res=mul(res,x) ; y>>=1 ; x=mul(x,x);} return res;}
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}
using namespace std;
list < pair < int , int > > s;
char buffer[2048];
list < int > test;
int dx , dy , upx , downx , ly , ry , N , M;
bool judge( pair < int , int > p ){
int x = p.first , y = p.second;
if( x - upx <= 0 ) return false;
if( x + downx > N ) return false;
if( y + ry > M ) return false;
if( y - ly <= 0 ) return false;
return true;
}
int main(int argc,char *argv[]){
scanf("%d%d",&N,&M);
for(int i = 1 ; i <= N ; ++ i) for(int j = 1 ; j <= M ; ++ j) s.push_back( mp(i , j) );
int ok = 0;
for(int i = 1 ; i <= 50000 ; ++ i){
while( !judge( s.front() ) ) s.pop_front();
printf("%d %d\n" , s.front().first + dx , s.front().second + dy );
s.pop_front();
fflush( stdout );
sf("%s",buffer);
int len = strlen(buffer);
if( len > 1 ){
ok = 1;
break;
}else{
char c = buffer[0];
if( c == 'U' ){
-- dx;
upx = max( upx , - dx );
}else if( c == 'D' ){
++ dx;
downx = max( downx , dx );
}else if( c == 'L' ){
-- dy;
ly = max( ly , -dy );
}else{
++ dy;
ry = max( ry , dy );
}
}
}
assert( ok == 1 );
return 0;
}
2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem K. KMC Attacks 交互题 暴力的更多相关文章
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem I. Interest Targeting 模拟题
Problem I. Interest Targeting 题目连接: http://codeforces.com/gym/100714 Description A unique display ad ...
- 2013-2014 ACM-ICPC, NEERC, Southern Subregional Contest Problem D. Grumpy Cat 交互题
Problem D. Grumpy Cat 题目连接: http://www.codeforces.com/gym/100253 Description This problem is a littl ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem D. Distance 迪杰斯特拉
Problem D. Distance 题目连接: http://codeforces.com/gym/100714 Description In a large city a cellular ne ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem C. Contest 水题
Problem C. Contest 题目连接: http://codeforces.com/gym/100714 Description The second round of the annual ...
- 2016-2017 ACM-ICPC, NEERC, Moscow Subregional Contest Problem L. Lazy Coordinator
题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229511 时间限制:1s 空间限制:512MB 题目大意: 给定一个n 随后跟着2n行输入 ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem J. Joke 水题
Problem J. Joke 题目连接: http://codeforces.com/gym/100714 Description The problem is to cut the largest ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem H. Hometask 水题
Problem H. Hometask 题目连接: http://codeforces.com/gym/100714 Description Kolya is still trying to pass ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem F. Finance 模拟题
Problem F. Finance 题目连接: http://codeforces.com/gym/100714 Description The Big Boss Company (BBC) pri ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem A. Alien Visit 计算几何
Problem A. Alien Visit 题目连接: http://codeforces.com/gym/100714 Description Witness: "First, I sa ...
随机推荐
- bzoj千题计划261:bzoj3294: [Cqoi2011]放棋子
http://www.lydsy.com/JudgeOnline/problem.php?id=3294 如果一个颜色的棋子放在了第i行第j列,那这种颜色就会占据第i行第j列,其他颜色不能往这儿放 设 ...
- 内网服务器通过Squid代理访问外网
环境说明 项目整体需部署Zabbix监控并配置微信报警,而Zabbix Server并不能访问外网,故运维小哥找了台能访问外网的服务器做Suqid代理,Zabbix Server服务器通过代理服务器访 ...
- Flex 界面初始化 自定义 预加载 类!
说明: 自定义界面初始化过程提示:初始化...,初始化完毕,加载完毕! ZPreloader.as package com.command { import flash.display.Graphic ...
- HDU 1869 六度分离 最短路
解题报告: 1967年,美国著名的社会学家斯坦利·米尔格兰姆提出了一个名为“小世界现象(small world phenomenon)”的著名假说,大意是说,任何2个素不相识的人中间最多只隔着6个人, ...
- bzoj3029 守卫者的挑战 (多维dp)
题面: 打开了黑魔法师Vani的大门,队员们在迷宫般的路上漫无目的地搜寻着关押applepi的监狱的所在地.突然,眼前一道亮光闪过."我,Nizem,是黑魔法圣殿的守卫者.如果你能通过我的挑 ...
- 洛谷 P4910 帕秋莉的手环 矩阵乘法+快速幂详解
矩阵快速幂解法: 这是一个类似斐波那契数列的矩乘快速幂,所以推荐大家先做一下下列题目:(会了,差不多就是多倍经验题了) 注:如果你不会矩阵乘法,可以了解一下P3390的题解 P1939 [模板]矩阵加 ...
- Centos6.5下rsync+inotify的配置详解
Centos 6.5配置rsync+inotify实现文件实时同步 1.安装rsync(两台机器执行相同的步骤) yum install gcc yum install rsyncd xinetd - ...
- oracle数据库查询重复记录
1.row_number()方法 1 2 3 4 5 6 7 8 9 10 11 SELECT row_number () over ( PARTITION BY v.acti ...
- springcloud Zuul中路由配置细节
上篇文章我们介绍了API网关的基本构建方式以及请求过滤,小伙伴们对Zuul的作用应该已经有了一个基本的认识,但是对于路由的配置我们只是做了一个简单的介绍,本文我们就来看看路由配置的其他一些细节. 首先 ...
- Codeforces 600E - Lomsat gelral 「$Dsu \ on \ tree$模板」
With $Dsu \ on \ tree$ we can answer queries of this type: How many vertices in the subtree of verte ...