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 ...
随机推荐
- python -- peewee处理数据库连接
目前,实现了的Database子类有三个:SqliteDatabase.MySQLDatabase.PostgresqlDatabase class SqliteDatabase(Database) ...
- 服务器监控zabbix
nagios服务器安装:http://www.jb51.net/article/79496.htm默认端口12489 nagios +ndo2db+mysqlhttps://www.cnblogs.c ...
- 【Step By Step】将Dotnet Core部署到Docker上
本教程的前提是,你已经在Linux服务器上已经成功的安装了Docker,我会大概介绍在此过程中用到的Docker命令,并不会介绍所有的Docker命令(因为我也不会). 一.在Docker中运行Dot ...
- 1.高并发教程-基础篇-之nginx负载均衡的搭建
温馨提示:请不要盲目的进行横向扩展,优先考虑对单台服务器的性能优化,只有单台服务器的性能达到最优化之后,集群才会被最大的发挥作用. 一.架构图: 服务器准备:3台,ubuntu16.04系统maste ...
- chkconfig设置开机自启动的原理
开机自启动服务的原理$ sshd on #手动设置3级别的开机自启动 [leiyf@leiyangfeng ~] #手动设置3级别的开机自启动,实质是在对应运行级别的目录rc3.d下创建一个sshd的 ...
- MongoDB数据库 : 管道,用户管理,副本集等
聚合(aggregate): db.集合.aggregate([{管道:{表达式}}]) db.集合.aggregate([ {管道1:{表达式1}}, {管道2:{表达式2}}, ... ...]) ...
- 动态链接库 —— Dll 基础
1. DLL 的初识 在 windows 中,动态链接库是不可缺少的一部分,windows 应用程序程序接口提供的所有函数都包含在 DLL 中,其中有三个非常重要的系统 DLL 文件,分别为 Kern ...
- 飞控入门之C语言结构体、枚举
结构体 先来说明一下,结构体存在的意义.比如说有一只猫,要在C语言程序中综合描述它,那么可以这样说,它的体重是float类型的,颜色是char类型的,它的一些食物名字是一个数组,那么如果分开定义这些变 ...
- aircrack-ng 破解无线网络
1.科普当今时代,wifi 已成为我们不可缺少的一部分,上网.看视频.玩游戏,没有 wifi 你就等着交高额的流量费吧,本来我想单独的写 wpa 破解和 wps 破解,后来觉得分开写过于繁琐,索性合并 ...
- 什么是PHP7中的孤儿进程与僵尸进程
什么是PHP7中的孤儿进程与僵尸进程 基本概念 我们知道在unix/linux中,正常情况下,子进程是通过父进程创建的,子进程在创建新的进程.子进程的结束和父进程的运行是一个异步过程,即父进程永远无法 ...