OUC_Summer Training_ DIV2_#14 724
又落下好多题解啊。。。先把今天的写上好了。
Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Description
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint on the i-th block. If there already is a footprint on the i-th block, the new footprint will cover the old one.

At the beginning, there were no footprints. Then polar bear Alice starts from the s-th block, makes a sequence of moves and ends in the t-th block. It is known that Alice never moves outside of the road.
You are given the description of Alice's footprints. Your task is to find a pair of possible values of s, t by looking at the footprints.
Input
The first line of the input contains integer n (3 ≤ n ≤ 1000).
The second line contains the description of the road — the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint).
It's guaranteed that the given string contains at least one character not equal to ".". Also, the first and the last character will always be ".". It's guaranteed that a solution exists.
Output
Print two space-separated integers — the values of s and t. If there are several possible solutions you can print any of them.
Sample Input
9
..RRLL...
3 4
11
.RRRLLLLL..
7 5
Hint
The first test sample is the one in the picture.
题目很简单啦,就是给一串足迹,输出一组可能的起始终止的坐标。值得注意的是,本题只有3种情况,全R 全L 有R有L 在第三种情况里只有R在(且全在)L右边的情况。(只有向右走后才有向左走的权利)只输出一种结果就好了。
#include<stdio.h>
int main()
{
char s[];
int n,i,a,b;
int flag = ,m = ,num = ;
scanf("%d",&n);
char c = getchar();//直接getchar的话出了错误source code error,但是又交了一次却对了
scanf("%c",&s[]);
for(i = ;i < n;i++)
{
scanf("%c",&s[i]);
if(s[i] != '.')
{
num ++;
if(m == )m = i;
if(s[i - ] != '.'&&flag == && s[i] != s[i - ])flag = ;
}
}
if(flag == )
{
if(s[m] == 'R')
{
a = m + ;
b = a + num;
}
if(s[m] == 'L')
{
b = m;
a = b + num;
}
}
else
{
for(i = m;s[i] != '.' && i < n;i++)
{
if(s[i] == 'L')
{
a = m+;
b = i;
break;
}
}
}
printf("%d %d\n",a,b);
return ;
}
Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Description
The polar bears are going fishing. They plan to sail from (sx, sy) to (ex, ey). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, west or north. Assume the boat is currently at (x, y).
- If the wind blows to the east, the boat will move to (x + 1, y).
- If the wind blows to the south, the boat will move to (x, y - 1).
- If the wind blows to the west, the boat will move to (x - 1, y).
- If the wind blows to the north, the boat will move to (x, y + 1).
Alternatively, they can hold the boat by the anchor. In this case, the boat stays at (x, y). Given the wind direction for t seconds, what is the earliest time they sail to (ex, ey)?
Input
The first line contains five integers t, sx, sy, ex, ey (1 ≤ t ≤ 105, - 109 ≤ sx, sy, ex, ey ≤ 109). The starting location and the ending location will be different.
The second line contains t characters, the i-th character is the wind blowing direction at the i-th second. It will be one of the four possibilities: "E" (east), "S" (south), "W" (west) and "N" (north).
Output
If they can reach (ex, ey) within t seconds, print the earliest time they can achieve it. Otherwise, print "-1" (without quotes).
Sample Input
5 0 0 1 1
SESNW
4
10 5 3 3 6
NENSWESNEE
-1
Hint
In the first sample, they can stay at seconds 1, 3, and move at seconds 2, 4.
In the second sample, they cannot sail to the destination.
又是一道很简单的题呀,可是却一直wa啊,原来是一个比较简单的地方疏忽了。题的意思是船的行走有四个方向,每次走1(可以不走),给出起点和终点,及每秒的风向。输出到达目的地的最少时间,若不能到达,输出-1.我的方法是,因为船只能走折线到达目的地,根据起末位置确定是N(S)W(E)需要出现的次数即可。
#include<stdio.h>
int main()
{
int t,sx,sy,ex,ey;
char str[];
scanf("%d%d%d%d%d",&t,&sx,&sy,&ex,&ey);
scanf("%s",str);
int i,n = ,s = ,e = ,w = ;
if(ex - sx < )w = sx - ex;
else e = ex - sx;
if(ey - sy < )s = sy - ey;
else n = ey - sy;
int N = ,S = ,E = ,W = ;
if((s == && n == ) &&( w == && e == ))
{
printf("0\n");
return ;
}
for(i = ;i< t;i++)
{
if(str[i] == 'N'&& n != && N < n)N++;//一开始就是因为没有N < n的条件就一直错。原因是N的次数已经达到条件时若其他条件还未完成N就还会增加,这样肯定就没有结果了
else if(str[i] == 'S' && s!= && S < s)S++;
else if(str[i] == 'E' && e != && E < e)E++;
else if(str[i] == 'W'&& w != && W < w)W++;
if((S == s && W == w)&&( E == e&& N == n)){printf("%d\n",i+);return ;}
}
printf("-1\n");
return ;
}
Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Description
It is known that there are k fish species in the polar ocean, numbered from 1 to k. They are sorted by non-decreasing order of their weight, which is a positive number. Let the weight of the i-th type of fish be wi, then 0 < w1 ≤ w2 ≤ ... ≤ wk holds.
Polar bears Alice and Bob each have caught some fish, and they are guessing who has the larger sum of weight of the fish he/she's caught. Given the type of the fish they've caught, determine whether it is possible that the fish caught by Alice has a strictly larger total weight than Bob's. In other words, does there exist a sequence of weights wi (not necessary integers), such that the fish caught by Alice has a strictly larger total weight?
Input
The first line contains three integers n, m, k (1 ≤ n, m ≤ 105, 1 ≤ k ≤ 109) — the number of fish caught by Alice and Bob respectively, and the number of fish species.
The second line contains n integers each from 1 to k, the list of fish type caught by Alice. The third line contains m integers each from 1 to k, the list of fish type caught by Bob.
Note that one may have caught more than one fish for a same species.
Output
Output "YES" (without quotes) if it is possible, and "NO" (without quotes) otherwise.
Sample Input
3 3 3
2 2 2
1 1 3
YES
4 7 9
5 2 7 3
3 5 2 7 3 8 7
NO
Hint
In the first sample, if w1 = 1, w2 = 2, w3 = 2.5, then Alice has a total of 2 + 2 + 2 = 6 weight units, while Bob only has 1 + 1 + 2.5 = 4.5.
In the second sample, the fish that Alice caught is a subset of Bob's. Therefore, the total weight of Bob’s fish is always not less than the total weight of Alice’s fish.
题意是有很多不同种类的鱼,种类用实数代表,题目给出的是鱼的种类数,(质量可以任意定,符合规则就好)相同种类的鱼质量相同,不同种类的鱼随着种类数的递增,质量也递增(相同也行)给出A,B两人所捕的鱼的情况,判断是否可能始A的鱼的总重量 绝对 大于B的鱼的总重量。
我的思路是这样的,若A的鱼的个数大于B的话一定可能(YES),因为可以始所有鱼的重量相同。若A鱼的个数不必B多的话,使A的总重量大于B就有很多种情况了,讨论起来太不方便。但反过来想,使B的总重量小于A的情况只有一种,那就是A中所有鱼的种类都小于或等于B的种类(换句话说,就是对于A中的所有种类,总能在B中找到比A种类大的)。
#include <algorithm>
#include <iostream>
using namespace std;
int a[],b[];
int main()
{
int n,m,k;
int j,i;
int flag = ;
cin>>n>>m>>k;
for( i=;i<n;i++)
cin >> a[i];
for( i=;i<m;i++)
cin >> b[i];
sort(a,a+n);
sort(b,b+m);
if(n > m)cout << "YES\n";
else
{
for(i = ,j = ;i<n && j < m;)
{
if(a[i] <= b[j])
{
i++;
j++;
}
else j++;
}
if(i==n ) cout<<"NO\n";
else cout << "YES\n";
}
return ;
}
OUC_Summer Training_ DIV2_#14 724的更多相关文章
- OUC_Summer Training_ DIV2_#16 725
今天做了这两道题真的好高兴啊!!我一直知道自己很渣,又贪玩不像别人那样用功,又没有别人有天赋.所以感觉在ACM也没有学到什么东西,没有多少进步.但是今天的B题告诉我,进步虽然不明显,但是只要坚持努力的 ...
- OUC_Summer Training_ DIV2_#13 723afternoon
A - Shaass and Oskols Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I ...
- OUC_Summer Training_ DIV2_#12(DP1) 723
这一次是做练习,主要了解了两个算法,最大子矩阵和,最长上升子序列. 先看题好啦. A - To The Max Time Limit:1000MS Memory Limit:32768KB ...
- OUC_Summer Training_ DIV2_#2之解题策略 715
这是第一天的CF,是的,我拖到了现在.恩忽视掉这个细节,其实这一篇只有一道题,因为这次一共做了3道题,只对了一道就是这一道,还有一道理解了的就是第一篇博客丑数那道,还有一道因为英语实在太拙计理解错了题 ...
- OUC_Summer Training_ DIV2_#7 718
是18号做的题啦,现在才把报告补上是以前不重视报告的原因吧,不过现在真的很喜欢写报告,也希望能写一些有意义的东西出来. A - Dragons Time Limit:2000MS Memory ...
- OUC_Summer Training_ DIV2_#11 722
企鹅很忙系列~(可惜只会做3道题T_T) A - A Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d &am ...
- OUC_Summer Training_ DIV2_#9 719
其实自己只会做很简单的题,有时都不想写解题报告,觉得不值得一写,但是又想到今后也许就不会做ACM了,能留下来的东西只有解题报告了,所以要好好写,很渣的题也要写,是今后的纪念. B - B Time L ...
- OUC_Summer Training_ DIV2_#5
这是做的最好的一次了一共做了4道题 嘻嘻~ A - Game Outcome Time Limit:2000MS Memory Limit:262144KB 64bit IO For ...
- OUC_Summer Training_ DIV2_#4之数据结构
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26100#problem/A A - A Time Limit:1000MS Me ...
随机推荐
- BFC渲染机制
BFC(block formatting context):块级格式化上下文(实际就是一个隔离罩) W3C CSS2.1 规范中的一个概念.它是页面中的一块渲染区域,并且有一套渲染规则,它决定了其子元 ...
- C++ STL 之 容器的深拷贝和浅拷贝
如果我们没有提供拷贝构造函数,没有重载=操作符,vector 对我们的 mc 对象进行的简单的浅拷贝,将拷贝的对象插入到容器中,导致我们的 mc 对象的 data 指针和容器中mc 对象的拷贝对象中的 ...
- 销售订单(SO)-API-创建销售订单
创建销售订单API主要注意几点: 初始化环境变量:fnd_global.apps_initialize(); mo_global.init('ONT'); mo_global.set_policy_c ...
- Python 针对Excel操作
1.python 读取Excel # -*- coding: utf-8 -*- import xlrd import os,sys reload(sys) sys.setdefaultencodin ...
- 关于百度Tongji Api的文档补充
百度统计的Tongji Api好像没有人维护了,文档缺胳膊少腿也没人理. 今天在这里指出其中一点,因为这一点花时间也没有傻思考的乐趣的. 引用自百度Tongji API文档 这个文档缺了很多东西,其中 ...
- 【1】Git基础
一.Git概念 1.1.Git定义 Git 是一个开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目.Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而开发 ...
- (十二)A64
一.AC108驱动移植 1.驱动添加 cp r18/lichee/linux-4.4/sound/soc/codecs/ac108.* a64/linux-3.10/sound/soc/codecs/ ...
- cas多方式登录相关知识点的总结
知识点: cas多表单登录(在用户名,密码的基础上,增加短信验证码登录) 自定义认证策略 自定义字段添加为空校验的错误信息 Controller层接口的调用 一:场景 项目涉及到的业务是,在原cas用 ...
- SpiderMan成长记(爬虫之路)
第一章 爬虫基础 1.1 爬虫基本原理 1.2 请求库 -- urllib库的使用 1.3 请求库 -- requests库的使用 1.4 数据解析 -- 正则基础 1.5 数据解析 -- lxml与 ...
- 好不容易当上技术管理者,却时常担心被下属diss技术水平,怎么办?
作者 | 刘建国出处 | 极客时间<技术管理实战 36 讲>专栏编辑 | Natalie 转型做管理后,你可以用在技术上的时间会越来越少,尤其是写代码的机会越来越少,手越来越生,但是要做的 ...