从(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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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> ...

  4. 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> ...

  5. Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)

    考场上只做出了ABDE C都挂了... 题解: A 题解: 模拟 判断前面一段是否相同,后面一段是否相同,长度是否够(不能有重叠) Code: #include<stdio.h> #inc ...

  6. 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( ...

  7. 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 ...

  8. Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) B. Weakened Common Divis

    题目链接 让你找一个数,使得这个数,可以被每个二元组的两个数中的一个数整除. 先将第一个二元组的两个数质因数分解一下,分解的质数加入set中,然后,对剩下的n-1个二元组进行遍历,每次遍历到的二元组对 ...

  9. 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 ...

随机推荐

  1. 内核调试工具——strace

    简介 strace常用来跟踪进程执行时的系统调用和所接收的信号. 在Linux世界,进程不能直接访问硬件设备,当进程需要访问硬件设备(比如读取磁盘文件,接收网络数据等等)时,必须由用户态模式切换至内核 ...

  2. 大话Linux内核中锁机制之内存屏障、读写自旋锁及顺序锁

    大话Linux内核中锁机制之内存屏障.读写自旋锁及顺序锁 在上一篇博文中笔者讨论了关于原子操作和自旋锁的相关内容,本篇博文将继续锁机制的讨论,包括内存屏障.读写自旋锁以及顺序锁的相关内容.下面首先讨论 ...

  3. iOS 地图相关

    参考博文:https://blog.csdn.net/zhengang007/article/details/52858198?utm_source=blogxgwz7 1.坐标系 目前常见的坐标系有 ...

  4. SQL分页过多时, 如何优化

    问题: 我们经常会使用到分页操作,这里有个问题,在偏移量非常大的时候,它会导致MySQL扫描大量不需要的行然后再抛弃掉.如: , ; 上述这条SQL语句需要查询10020条记录然后只返回最后20条.前 ...

  5. 小程序中 function (res)的理解

    刚看到小程序里面一段代码 success: function (res) { console.log('搜索结果:'); console.log(res); wx.hideToast(); if (r ...

  6. Home Assistant系列 -- 基于树莓派安装并设置自启动

    Home Assistant 是当前智能家居最火热的开源DIY 软件,之前的文章  智能家居系统 Home Assistant 系列 --介绍篇  已经详细介绍过了,这里就不详细介绍了,今天介绍 如何 ...

  7. Java HashMap 源代码分析

    Java HashMap jdk 1.8 Java8相对于java7来说HashMap变化比较大,在hash冲突严重的时候java7会退化为链表,Java8会退化为TreeMap 我们先来看一下类图: ...

  8. C语言程序设计:现代方法(第2版)第三章全部习题答案

    前言 本人在通过<C语言程序设计:现代方法(第2版)>自学C语言时,发现国内并没有该书完整的课后习题答案,所以就想把自己在学习过程中所做出的答案分享出来,以供大家参考.这些答案是本人自己解 ...

  9. 5.18-笨办法学python-习题16(write)

    from sys import argv script,filename=argv #固定模式啦 print("we're going to erase %r."%filename ...

  10. ASP.NET的服务端验证(干货)

    最近有项目需要使用.net的web,啥也不说,直接开始学习.net的mvc框架.感觉微软的web项目其实还是很好用的,今天和大家分享一下服务端验证的事情.其实原理就是用到了c#的特性,特性不用多说,大 ...