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题, 总会有些收获, 慢慢进步.

 

题目

Examples
input
6
2 1 5 2 7 4
output
YES
2 3 1 6
input
5
1 3 1 9 20
output
NO
Note

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题收获不小的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 【打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 ...

随机推荐

  1. k8s 开船记-脚踏两只船:船儿还是旧的好,不翻船才是硬道理

    自从上次开始脚踏两只船(2个独立的k8s集群同时运行),园子暂时用奢侈的土豪方式过上了安稳的船上生活. 这种方式除了费钱之外,还带来一个问题,我们的集装箱自动装船系统(基于gitlab-ci的自动化部 ...

  2. 嵌入式Linux应用开发完全手册之环境搭建

    @ 目录 0.下载源配置 1.电脑BIOS启动虚拟化 2.linux网卡查看与IP设置 3.windows NAT虚拟网络配置 4.修改 Ubuntu 的 mountd 端口 5.vim设置 6.Mo ...

  3. dedecms 5.7 任意前台用户修改漏洞

    一. 启动环境 1.双击运行桌面phpstudy.exe软件 2.点击启动按钮,启动服务器环境 二.代码审计 1.双击启动桌面Seay源代码审计系统软件 2.点击新建项目按钮,弹出对画框中选择(C:\ ...

  4. 内网渗透----Linux信息收集整理

    一.基础信息收集 1.查看系统类型 cat /etc/issue cat /etc/*-release cat /etc/lsb-release cat /etc/redhat-release 2.内 ...

  5. Servlet的response乱码问题

    一.response有两种输出流(编码:UTF-8): 1.字节流:response.getOutputStream().write(date.getBytes("UTF-8")) ...

  6. tomcat 部署war,umask上传文件后无法通过nginx反向代理访问上传后的文件

    Catalina.sh文件,把umask修改为 0022 即可. 引用:https://tomcat.apache.org/tomcat-8.5-doc/security-howto.html

  7. switch语句能否作用在byte上,能否作用在long上,能否作用在String上?

    在Java 7以前,在switch(expr1)中,expr1只能是一个整数表达式(但不包括long和Long)或者枚举常量,整数表达式可以是int基本类型或Integer包装类型,byte.shor ...

  8. 是否可以继承String类?

    String 类是final类,不可以被继承. 补充:继承String本身就是一个错误的行为,对String类型最好的重用方式是关联关系(Has-A)和依赖关系(Use-A)而不是继承关系(Is-A) ...

  9. Kafka 分区的目的?

    分区对于 Kafka 集群的好处是:实现负载均衡.分区对于消费者来说,可以提高并发度,提高效率.

  10. Redis的集群搭建(四)

    1.redis-cluster架构图 2.redis-cluster投票:容错 架构细节: (1)所有的redis节点彼此互联(PING-PONG机制),内部使用二进制协议优化传输速度和带宽. (2) ...