Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) E. Down or Right
从(1,1,n,n)每次只变一个坐标,进行询问。
如果问到对角线有距离限制,
再从(1,1,n/2,n/2)询问到(n/2,n/2,n,n)
记住前半部分贪心忘上走,后本部分贪心往右走
因为最后的路线可能有多条
所以这样走的话一定能找到一条对角线在右上角的路线
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <functional>
#include <assert.h>
#include <iomanip>
using namespace std;
string ans, ans2;
char seq[5];
int main() {
int n;
while(~scanf("%d", &n)) {
int l = n, r = n;
ans.clear();
while(1) {
printf("? %d %d %d %d\n", 1, 1, l-1, r); fflush(stdout);
scanf("%s", seq);
if(seq[0] == 'Y') {
l --;
ans += 'D';
} else {
r --;
ans += 'R';
}
if(l + r == n + 1) break;
}
int cnt = ans.length() - 1;
int l2 = l; int r2 = r;
l = 1; r = 1;
int endL = l2;
ans2.clear();
while(1) {
assert(cnt >= 0);
if(ans[cnt] == 'D') l2 ++;
else r2 ++;
cnt --;
if(l == endL) {
// printf("%d %d\n", l2, r2);
for(int i = 0; i < (n+1 - l - r); ++i) ans2 += 'R';
break;
}
else {
printf("? %d %d %d %d\n", l, r+1, l2, r2); fflush(stdout);
}
scanf("%s", seq);
if(seq[0] == 'N') {
l ++;
ans2 += 'D';
} else {
r ++;
ans2 += 'R';
}
if(l + r == n+1) break;
}
reverse(ans.begin(), ans.end());
string ans3 = ans2 + ans;
printf("! %s\n", ans3.c_str());
fflush(stdout);
}
return 0;
}
/*
10
..#.......
...#......
......#...
.#.......#
..........
.........#
.......#..
.......#..
..........
..........
*/
Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) E. Down or Right的更多相关文章
- E - Down or Right Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)
http://codeforces.com/contest/1023/problem/E 交互题 #include <cstdio> #include <cstdlib> #i ...
- Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)-D- Array Restoration
我们知道不满足的肯定是两边大中间小的,这样就用RMQ查询两个相同等值的区间内部最小值即可,注意边界条件 #include<bits/stdc++.h> #define x first #d ...
- Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)-C-Bracket Subsequence
#include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> ...
- Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)-A-Single Wildcard Pattern Matching
#include<iostream> #include<algorithm> #include<stdio.h> #include<string.h> ...
- Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)
考场上只做出了ABDE C都挂了... 题解: A 题解: 模拟 判断前面一段是否相同,后面一段是否相同,长度是否够(不能有重叠) Code: #include<stdio.h> #inc ...
- D. Recovering BST Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)
http://codeforces.com/contest/1025/problem/D 树 dp 优化 f[x][y][0]=f[x][z][1] & f[z+1][y][0] ( gcd( ...
- Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) -B C(GCD,最长连续交替序列)
B. Weakened Common Divisor time limit per test 1.5 seconds memory limit per test 256 megabytes input ...
- Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) B. Weakened Common Divis
题目链接 让你找一个数,使得这个数,可以被每个二元组的两个数中的一个数整除. 先将第一个二元组的两个数质因数分解一下,分解的质数加入set中,然后,对剩下的n-1个二元组进行遍历,每次遍历到的二元组对 ...
- Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)
A : A. Doggo Recoloring time limit per test 1 second memory limit per test 256 megabytes input stand ...
随机推荐
- Redis的安装和部署(windows )
Redis是一个开源的试用ANSI C语言编写的.遵守BSD协议.支持网络.可基于内存可持久化的日志型.key-value数据库.通常被称为数据结构服务器. redis的数据类型有:字符串(strin ...
- Boost asio基本概念
asio库基于操作系统提供的异步机制,采用前摄器模式(Proactor)实现可移植的异步(或同步)IO操作,不需要使用多线程和锁,有效避免多线程编程带来的诸多有害副作用(如竞争,死锁). asio封装 ...
- iOS 根据url生成二维码贴到底图上
根据url 生成指定尺寸的二维码图片 UIImage * createBinaryCodeImg(const char * url ,CGFloat size) { //create binary c ...
- PyCharm 2018最新激活码通用
通用:Window.Mac.Ubantu都稳定有效,关键是这种激活方式不会产生其他影响 缺点:需要修改hosts文件 **1.修改hosts文件**将 0.0.0.0 account.jetbrain ...
- BZOJ 1941: [Sdoi2010]Hide and Seek(k-d Tree)
Time Limit: 16 Sec Memory Limit: 162 MBSubmit: 1712 Solved: 932[Submit][Status][Discuss] Descripti ...
- Java面试题整理2
多线程部分 并行和并发的区别? 并行指两个或多个事件同一时刻发生:并发指两个或多个事件同一时间间隔发生. 并行是在不同实体上的多个事件,并发是在同一实体上的多个事件. 线程和进程的区别? 进程是程序运 ...
- echarts中跨域动态获取数据时,当某些对应的数据为空时,鼠标滑动到所在位置卡死
才疏学浅,万望指点. formatter: function (params) { var rel = params[0].name + "<br />"; rel + ...
- HTML5 -- 浏览器数据缓存 -- indexedDB
IndexedDB是一种可以让你在用户的浏览器内持久化存储数据的方法,为web应用提供了丰富的查询功能,使我们的应用在在线和离线都能正常工作. 由于 IndexedDB 本身的规范还在持续演进中,当前 ...
- docker环境下构建flannel 网络
flannel 是coreos 开发的网络解决方案,为每一台主机分配一个 subnet,容器从此subnet 中分配ip,ip可以在主机间路由.每个subnet从更大的ip池中划分,为了在各个主机间共 ...
- dns欺骗之ettercap
ettercap是一个基于ARP地址欺骗方式的网络嗅探工具,主要适用于局域网. ettercap是一款现有流行的网络抓包软件,它利用计算机在局域网内进行通信的ARP协议的缺陷进行攻击,在目标与服务器之 ...