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 ...
随机推荐
- Infiniband基本知识
InfiniBand架构是一种支持多并发链接的“转换线缆”技术,在这种技术中,每种链接都可以达到2.5 Gbps的运行速度.这种架构在一个链接的时候速度是500 MB/秒,四个链接的时候速度是2 GB ...
- rocketmq命令【转】
首先进入 RocketMQ 工程,进入/RocketMQ/bin 在该目录下有个 mqadmin 脚本 . 查看帮助: 在 mqadmin 下可以查看有哪些命令 a: 查看具体命令的使 ...
- 阅读 CloudDPI:Cloud+DPI+Reversible Sketch
CloudDPI: Cloud-Based Privacy-Preserving Deep Packet Inspection via Reversible Sketch 与sketch的结合点:将修 ...
- Win 10安装11g 客户端条件检查失败,INS-30131 无法从节点 "desktop-njm3a7m" 检索 exectask 的版本
Win 10安装11g 客户端条件检查失败,[INS-30131] 执行安装程序验证所需的初始设置失败.无法从节点 "desktop-njm3a7m" 检索 exectask 的版 ...
- ionic ios 打包发布流程
1.ionic cordova resources ios 在windows下 生成ios资源包 2.拷贝ionic 项目到mac电脑 不用拷贝platforms 并解压 3.正常情况下wido ...
- ps加强总结
快捷键 1.ctrl+alt+z返回 2.ctrl+z撤销 3.ctrl+s保存 4.ctrl+shift+s另存为 5.shift是有序的选择 ctrl键是无序的选择 6.ctrl+g打组 ...
- 利用python操作mrjob实例---wordcount
网上利用java实现mr操作实例相对较多,现将python实现mr操作实例---Wordcount分享如下: 在操作前,需要作如下准备: 1.确保linux系统里安装有python3.5,pyt ...
- python2.7提示编码出错
学习python过程中经常会遇到一些问题. 比如编码出错,之前解决过.但是由于很长时间没有学习python,于是忘记解决的办法.这一次,从新开始学习又遇到了... 首先,报错提示编码出现问题: 于是通 ...
- c语言实验报告(四) 从键盘输入字符串a和字符串b,并在a串中的最小元素(不含结束符)后面插入字符串b.
a串中最小元素后的字符被舍弃了. #include<stdio.h>#include<string.h>void main(){ int i,min=0; char a[2 ...
- GD32F20x系列使用问题总结
GD单片机近几年越来越火了,既有他自身相比与ST的价格优势,也有支持国货的信仰加成.然而一个新的东西,或者说一个相对较新的东西,在使用的友好性和资料的完整性方面还有很长的路要走. 现将个人使用过程中碰 ...