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 ...
随机推荐
- Objective-C基础知识之“类”
Objective-C语言是iOS开发的专用语言,虽然现在在逐步被swift语言取代,但是仍可以作为基础学习,学会Objective-C之后入手swift也是相当快速.今天我来简谈一下关于OC中的类. ...
- vue-cli3详细config配置
const path = require('path') module.exports = { publicPath: './', // vueConf.baseUrl, // 根域上下文目录 // ...
- Redis数据库 : 基础
设置密码: /etc/redis/redis.conf 文件把 requirepass 取消注释并设置密码 取消只能本地登录的bind 同上面的配置文件 把 bind一行注释掉 带密码登录: redi ...
- HBase操作一
package Hbase; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.a ...
- aircrack-ng 破解无线网络
1.科普当今时代,wifi 已成为我们不可缺少的一部分,上网.看视频.玩游戏,没有 wifi 你就等着交高额的流量费吧,本来我想单独的写 wpa 破解和 wps 破解,后来觉得分开写过于繁琐,索性合并 ...
- Noip 2016 Day 1 & Day 2
Day 1 >>> T1 >> 水题直接模拟AC: 考察三个知识点:1.你能不能编程 2.你会不会取模 3.你脑子抽不抽 然而第一次评测还是90,因为当模运算时 “ en ...
- sed: unix与doc换行的转换
在Linux (Unix)平台下回车换行以\n表示 在Window平台下回车换行以\r\n表示 两者的差异导致了: 在window下看Linux的文本排版全乱 在Linux在看Window的文本则是存 ...
- Linux入门进阶第五天——用户管理(帐号管理 )下
一.身份切换 为了避免 rm -rf /* 的悲剧发生,平时使用时,尽量使用一般帐号!需要环境设置等必要时才使用root 1.su命令 一般地,推荐使用su - / su - username的形式来 ...
- 1.Delphi Rest后台+MUI前台开发App前言
尽管不是专业的程序猿,但是对Delphi的喜爱已经10多年了.一直以来用Delphi开发一些小应用若干个,同时用Delphi给朋友开发一些中小型的业务平台也有几个.可以说Delphi对于数据库的操作, ...
- PostgreSQL参数学习:wal_keep_segments
http://www.postgresql.org/docs/9.3/static/runtime-config-replication.html 参考官方文档: wal_keep_segments ...