Codeforces Round #707 (Div. 2)A.英语漏洞 + C.Going Home C题收获不小
A题英语漏洞
A题传送门: https://codeforces.com/contest/1501/problem/A
其实题目说的很明白, 只是我傻傻的会错了意, 话不多说, 开整.

前两行是说, 火车从i - 1站到 i 站所需时间,
下面的1说的是它在车站上的时间至少为⌈bi−ai⌉/2(除法用上限, 简言之就是带小数的去掉小数, 再加一)
要计算到达的时间, 显然就是这两者之和了, 我当时哈哈, 就判断时间是否大于等于这个第一条, 真爽, 看了半天没用的
传送门_C题: https://codeforces.com/contest/1501/problem/C
前言
一直以来, 做出c题的的次数不多, 但还是有看c题的时间的, 往后还是要和现在这样, 每次做完补掉c题, 总会有些收获, 慢慢进步.
题目

6
2 1 5 2 7 4
YES
2 3 1 6
5
1 3 1 9 20
NO
In the first example a2+a3=1+5=2+4=a1+a6a2+a3=1+5=2+4=a1+a6. Note that there are other answer, for example, 2 3 4 6.
In the second example, we can't choose four indices. The answer 1 2 2 3 is wrong, because indices should be different, despite that a1+a2=1+3=3+1=a2+a3
题意
仅一个输入样例, 需要在这n个数里找到四个数, 使得ax+ay=az+aw
收获
因为就一个输入样例,那就运行时间没这么长了,可以稍微放心大胆的弄下, n^2还是可以的.
还有就是这次颠覆了我怕数组开的太大的认知, 全局变量开到4e8, 丝毫没有问题, 运行时间的不足用存储来补, 哈哈.
而且,其实,我还没在主函数写过两个return呢,往后方便的时候试试.
又是有收获的一次cf, 开心~~
解析
来个n^2的遍历, 对于每次ax+ay都在数组里记录下值的大小, 并保留i, j的值, 像这样
x[s]=i;y[s]=j;//s=ax+ay
那么最后, 只要保证x[s]和y[s]!=0, 并且四个数序号不重复即可.
AC代码(代码还是很短的)
#include<iostream>
using namespace std;
int n;
int x[5000003],y[5000003],a[2500003];
int main(){
scanf("%d",&n);
for(int i=1;i<=n;++i)scanf("%d",&a[i]);
for(int i=1;i<=n;++i){
for(int j=i+1;j<=n;++j){
int s=a[i]+a[j];
if(x[s]&&x[s]!=i&&x[s]!=j&&y[s]!=i&&y[s]!=j){
printf("YES\n%d %d %d %d",i,j,x[s],y[s]);
return 0;
}
x[s]=i;y[s]=j;
}
}
printf("NO\n");
return 0;
}
Codeforces Round #707 (Div. 2)A.英语漏洞 + C.Going Home C题收获不小的更多相关文章
- Codeforces Round #369 (Div. 2)---C - Coloring Trees (很妙的DP题)
题目链接 http://codeforces.com/contest/711/problem/C Description ZS the Coder and Chris the Baboon has a ...
- Codeforces Round #385 (Div. 2) A. Hongcow Learns the Cyclic Shift 水题
A. Hongcow Learns the Cyclic Shift 题目连接: http://codeforces.com/contest/745/problem/A Description Hon ...
- Codeforces Round #356 (Div. 2)B. Bear and Finding Criminals(水题)
B. Bear and Finding Criminals time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
- Codeforces Round #396 (Div. 2) A. Mahmoud and Longest Uncommon Subsequence 水题
A. Mahmoud and Longest Uncommon Subsequence 题目连接: http://codeforces.com/contest/766/problem/A Descri ...
- Codeforces Round #375 (Div. 2) A. The New Year: Meeting Friends 水题
A. The New Year: Meeting Friends 题目连接: http://codeforces.com/contest/723/problem/A Description There ...
- Codeforces Round #258 (Div. 2) C. Predict Outcome of the Game 水题
C. Predict Outcome of the Game 题目连接: http://codeforces.com/contest/451/problem/C Description There a ...
- Codeforces Round #359 (Div. 2) B. Little Robber Girl's Zoo 水题
B. Little Robber Girl's Zoo 题目连接: http://www.codeforces.com/contest/686/problem/B Description Little ...
- Codeforces Round #358 (Div. 2) B. Alyona and Mex 水题
B. Alyona and Mex 题目连接: http://www.codeforces.com/contest/682/problem/B Description Someone gave Aly ...
- 【打CF,学算法——二星级】Codeforces Round #313 (Div. 2) B. Gerald is into Art(水题)
[CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/B 题面: B. Gerald is into Art time limit per t ...
随机推荐
- 【公告】淘宝 npm 域名即将切换 && npmmirror 重构升级
镜像下载.域名解析.时间同步请点击阿里云开源镜像站 前言 本文将包括两部分内容: 淘宝 npm 域名即将停止解析 npmmirror 镜像站大重构升级 原淘宝 npm 域名即将停止解析 正如在< ...
- 放在initramfs的ko会先加载,还是/lib/modules/下面的ko会先加载?
如果是在switchroot时加载,用的是initramfs,在switchroot后,用的是硬盘上的,有些ko放到initramfs中,但是switchroot前不加载的话,用的还是硬盘上的,关键看 ...
- QT designer的安装与汉化(pycharm)
QT designer的安装 1.安装好Python3的环境 添加环境变量,保证安装正确, 2.安装PyQt5 采用命令安装,Win+R,输入CMD,打开命令框,输入以下命令.后面是豆瓣的镜像地址,是 ...
- maven国内镜像配置
Maven是当前流行的项目管理工具,但官方的库在国外经常连不上,连上也下载速度很慢.国内oschina的maven服务器很早之前就关了.今天发现阿里云的一个中央仓库,亲测可用. 1 <mirro ...
- FOC实现概述
FOC原理框图如下: 其中涉及到两种坐标转换: 1. Clark变换:常规的三相坐标系→静止的二相坐标系α.β 正变换矩阵 $\left[ {\begin{array}{*{20}{c}}{\sqrt ...
- IDEA端口占用的解决方案
使用端口查找到对应的进程PID: netstat -ano | findstr "端口" 查找到对应PID的进程信息 tasklist /v /fi "PID eq &l ...
- 序列化接口的id有什么用?
反序列化Java对象时必须提供该对象的class文件,现在的问题是随着项目的升级,系统的class文件也会升级,Java如何保证两个class文件的兼容性? Java序列化机制允许为序列化类提供一个p ...
- SpringAOP 失效解决方案、Spring事务失效
SpringAOP 失效解决方案 SpringAOP是基于代理来对目标方法进行增强,但是有的时候又会出现"增强无效"的情况,比如在@Transactional下的某类中的方法内调用 ...
- Jinkins流水线脚本使用curl命令调用服务接口,并且使用url传参。
curl http://xxx.xx.xx.xx:xxxx/jenkins/publish?fileName=${fileName}&tag_name=${tag_name} 如图调用不符合c ...
- MySQL索引如何优化?二十条铁则
索引的相信大家都听说过,但是真正会用的又有几人?平时工作中写SQL真的会考虑到这条SQL如何能够用上索引,如何能够提升执行效率? 前言 索引的相信大家都听说过,但是真正会用的又有几人?平时工作中写S ...