Codeforces1023E Down or Right 【贪心】
题目分析:
从起点开始询问终点连通性,优先右走。从终点开始询问起点连通性,优先上走。
代码:
#include<bits/stdc++.h>
using namespace std; int n; int query(int x1,int y1,int x2,int y2){
printf("? %d %d %d %d\n",x1,y1,x2,y2);
fflush(stdout);
char str[];
scanf("%s",str);
if(str[] == 'Y') return ;
else return ;
//int z; scanf("%d",&z);
//return z;
} stack<char> sta;
vector <char> vc;
void work(){
int x = ,y = ;
while(n-x+n-y > n-){
int z = query(x,y+,n,n);
if(z){vc.push_back('R');y++;}
else{vc.push_back('D');x++;}
}
int nx = n,ny = n;
while(nx != x || ny != y){
int z = query(,,nx-,ny);
if(z){sta.push('D');nx--;}
else{sta.push('R');ny--;}
}
printf("! ");
for(int i=;i<vc.size();i++) printf("%c",vc[i]);
while(!sta.empty()){printf("%c",sta.top());sta.pop();}
} int main(){
scanf("%d",&n);
work();
return ;
}
Codeforces1023E Down or Right 【贪心】的更多相关文章
- BZOJ 1692: [Usaco2007 Dec]队列变换 [后缀数组 贪心]
1692: [Usaco2007 Dec]队列变换 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 1383 Solved: 582[Submit][St ...
- HDOJ 1051. Wooden Sticks 贪心 结构体排序
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- HDOJ 1009. Fat Mouse' Trade 贪心 结构体排序
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- BZOJ 1691: [Usaco2007 Dec]挑剔的美食家 [treap 贪心]
1691: [Usaco2007 Dec]挑剔的美食家 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 786 Solved: 391[Submit][S ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【BZOJ-4245】OR-XOR 按位贪心
4245: [ONTAK2015]OR-XOR Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 486 Solved: 266[Submit][Sta ...
- code vs 1098 均分纸牌(贪心)
1098 均分纸牌 2002年NOIP全国联赛提高组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题解 题目描述 Description 有 N 堆纸牌 ...
- 【BZOJ1623】 [Usaco2008 Open]Cow Cars 奶牛飞车 贪心
SB贪心,一开始还想着用二分,看了眼黄学长的blog,发现自己SB了... 最小道路=已选取的奶牛/道路总数. #include <iostream> #include <cstdi ...
- 【贪心】HDU 1257
HDU 1257 最少拦截系统 题意:中文题不解释. 思路:网上有说贪心有说DP,想法就是开一个数组存每个拦截系统当前最高能拦截的导弹高度.输入每个导弹高度的时候就开始处理,遍历每一个拦截系统,一旦最 ...
随机推荐
- Python股票分析系列——自动获取标普500股票列表.p5
该系列视频已经搬运至bilibili: 点击查看 欢迎来到Python for Finance教程系列的第5部分.在本教程和接下来的几节中,我们将着手研究如何为更多公司提供大量的定价信息,以及如何一次 ...
- 微信支付异常:appid and openid not match
上周调试微信小程序支付时遇到的问题,在调用统一下单接口获取微信支付的相关参数时,报了这么一个错误:appid and openid not match. 字面意思很容易理解,就是appid与openi ...
- python之间的基础
编程第一步 print('hello,world!') 变量名的命名的规则: 1:变量由字母,数字,下划线组成 2:变量不能以数字开头 3:禁止使用python中的关键字,如 'alse', 'Non ...
- Dockerfile cnetos7_nginx1.15.10
FROM centos:7 MAINTAINER yuyongxr yuyongxr@gmail.com LABEL Discription="centos7+nginx1.15.10&qu ...
- Spring Mvc和Spring Boot读取Profile方式
spring boot java代码中获取spring.profiles.active - u013042707的专栏 - CSDN博客https://blog.csdn.net/u013042707 ...
- pip ipython启动错误 Fatal error in launcher: Unable to create process using
完整的错误提示: C:\Users\yyy>ipython3Fatal error in launcher: Unable to create process using '"c:\u ...
- laravel中migration 数据迁移
简介 数据库迁移就像是数据库的版本控制,可以让你的团队轻松修改并共享应用程序的数据库结构.迁移通常与 Laravel 的数据库结构生成器配合使用,让你轻松地构建数据库结构.如果你曾经试过让同事手动在数 ...
- Oracle 检查约束check
--检查约束 create table test1( id ) primary key, email ) check (email like '%@%') ) drop table test1 ,'1 ...
- js中怎么使点击按钮后文本框获得焦点
<html> <head> <script type="text/javascript"> function setFocus() { docu ...
- Linux基础学习(16)--备份与恢复
第十六章——备份与恢复 一.备份概述 1.Linux系统需要备份的数据: 2.备份策略: 二.dump和restore命令 1.dump命令: 2.restore命令: