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,想法就是开一个数组存每个拦截系统当前最高能拦截的导弹高度.输入每个导弹高度的时候就开始处理,遍历每一个拦截系统,一旦最 ...
随机推荐
- 卷积神经网络CNN的意义
一.选用卷积的原因 局部感知 简单来说,卷积核的大小一般小于输入图像的大小(如果等于则是全连接),因此卷积提取出的特征会更多地关注局部 —— 这很符合日常我们接触到的图像处理.而每个神经元其实没有必要 ...
- c++_work
while((ch=getopt(argc, argv, "X:Y:C:")) != EOF) { switch((char)ch) { case 'X': strcpy(strS ...
- node express使用
var express = require('express'); var app = express(); app 对象具有以下的方法: 路由HTTP请求:app.METHOD和app.param. ...
- Python _内置函数3_45
reversed: #reversed() l = [1,2,3,4,5] l.reverse() print(l) #改变了原来的列表 l = [1,2,3,4,5] l2 = reversed(l ...
- Python学习第三篇——访问列表部分元素
dongman =["huoying","sishen","si wang bi ji","pan ni de lu lu xiu ...
- Array Division CodeForces - 808D (构造+实现)
Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into t ...
- 用python表白了!!!
用python 画一颗心,代码: import numpy as np import matplotlib.pyplot as plt x = np.linspace(-8 , 8, 1024) ...
- git出现: not a git repository
使用用git add . 出现这样错误: fatal: not a git repository (or any of the parent directories): .git 意思是说:.git没 ...
- js中的一些方法
数组 //map() 方法创建一个新数组,其结果是该数组中的每个元素都调用一个提供的函数后返回的结果. 返回值:一个新数组,每个元素都是回调函数的结果. var array1 = [1, 4, 9, ...
- html5-attr和prop
###1.什么是attrbute和property attribute(attr) html标签的预定义属性 checked html标签的自定义属性 a eg: <input ...