2017武汉大学校赛网络预选赛g题

09年ACM武汉大学网络赛试题 09年ACM区域赛 网络赛 武汉大学 包括题目(PDF)、测试数据和标程 立即下载

Input file: standard input
Output file: standard output
Time limit: 1 second
Memory limit: 512 mebibytes
Everyone hates the verdict “Time Limit Exceeded” or “TLE”. However, sometimes, we can’t come up with a “elegant” solution which is clear and fast.

Our problem setter also hates “TLE”, but he is dumb and can only work out what a problem is. He can’t really solve it. We called him “Zui Qiang Xuan Shou”

One day, he got a problem, again, he said “I got it! It is **”, he spoke so fast that no one knew what he said. Luckily, he typed his solution—

这里写图片描述
He said that it should get AC small cases, but he might receive “Time Limit Exceeded”.

As he clicked the “submit” button, the network is down. So he went to the dinning hall and ask you to correct his solution.

Your program should output exact same things as the program listed above.

Input
The format of input should make the program work if we don’t care about the time.

In the input file, all numbers are positive integers and no more than 10^610
​6
​​ .

Output
You should output what the program outputs if the time is unlimited.

Examples
Input 1
5
1 2 3 4 5
Output 1
0
Input 2
6
1 2 3 4 5 6
Output 2
0

题意:让你写一个程序,输入和输出跟上面一样。

解题思路:很明显上面就是一个冒泡排序的代码,答案就是这个数组的逆序对数目.那么求逆序对还不容易,树状数组就行,而且这题不需要离散化,很简单,上次听队友说求逆序数还可以用归并排序,方法很多,这里用树状数组的复杂度是n*logn,所有跑起来很快。

#include<stdio.h>
#include<iostream>
#include<cstring>
using namespace std;
const int maxn = 1e6 + 10;
typedef long long ll;
int n;
ll a[maxn];
ll Tree[2*maxn];
ll lowbit(ll x)
{
    return x&(-x);
}
ll get(ll x)
{
    ll sum = 0;
    for(ll i = x; i > 0; i -= lowbit(i))
    {
        sum += Tree[i];
    }
    return sum;
}
void update(ll x,ll value)
{
    for(ll i = x; i <= maxn; i += lowbit(i))
    {
        Tree[i] += value;
    }
}
int main()
{
    scanf("%d",&n);
    memset(Tree,0,sizeof(Tree));
    for(ll i = 1; i <= n; i++)
    {
        scanf("%lld",&a[i]);
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++)
    {
        ll res = get(a[i]);
        ans += i - 1 - res;
        update(a[i],1);
    }
    printf("%lld\n",ans);
    return 0;
}
【C语言学习疑难杂症】第20期:0x00007FF7F2821964处引发的异常0xC0000005写入位置 0x0000000000000 检查代码中是否存在野指针访问的情况,确保在进行写入操作之前,内存已经被正确分配或初始化,并且在使用完毕后进行了正确的释放。空指针访问:代码尝试在空指针地址(0x0000000000000000)处进行写入操作,导致访问冲突。检查代码中是否存在数组越界的情况,确保在进行写入操作之前,数组的索引值在合法范围内。检查代码中是否存在空指针访问的情况,确保在进行写入操作之前,指针已经被正确初始化。野指针访问:代码尝试在已释放或未初始化的内存地址进行写入操作,导致访问冲突。 阅读详情

相关推荐

ArcGIS新手必看:HWSD2土壤数据从下载到批量提取TIFF的完整流程

本文详细介绍了ArcGIS中HWSD2土壤数据的完整处理流程,从数据下载、预处理到批量提取TIFF文件。涵盖栅格属性表构建、属性数据连接及性能优化等关键步骤,帮助新手高效掌握HWSD2数据提取技术,提升地理信息数据处理效率。

ll5678的博客 1039

武汉大学校赛(个人总结+补题)

【题意】: B.Color Input file: standard input Output file: standard output Time limit: 1 second Memory limit: 512 mebibytes When Asuho was just a little girl, she has been loving stars, as there are

Crazy 2204

RK3588嵌入式开发:从零构建Rockit多媒体处理引擎的实战指南

本文详细介绍了如何在RK3588嵌入式平台上从零构建Rockit多媒体处理引擎的实战指南。涵盖开发环境搭建、工具链配置、源码编译流程、硬件加速优化及典型问题解决方案,帮助开发者高效利用RK3588的NPU和VPU加速特性,实现高性能多媒体处理应用。

mango的博客 189

Problem A. Scoring Board

Problem A. Scoring Board 广西2019年程序设计大赛第一题 Input file: standard input Output file: standard output Time limit: 1 second Memory limit: 512 megabytes In programming contests, the scoring board shows each team’s judge results. Assume there is only one p

Hxm1998的博客 408

电气自动化 基于plc智能大棚温室控制的系统设计

随着全球工业的快速发展,农业温室大棚的智能控制已经成为我国农业的第一大发展目标。温室内部绝大多数环境要素均实现了计算机化,此外,各类监测传感器配置完备,例如,能够实时监测温室内外部环境的温湿度、二氧化碳浓度、光照等数值,使得各级执行部门顺利实施自动控制。目前,国内温室已经在温湿度、二氧化碳浓度等方面配备完整相应的设备、设施,本文基于PLC设计智能大棚温室控制的系统,实现全方位的实时智能监控,为作物快速生长营造最优的环境。关键词;温室大棚;智能控制;PLC。

QQ1694456187的博客 2403

Unity游戏开发客户端面经——网络(初级)

Unity游戏开发客户端面经 之 网络 篇

Sea3752的博客 1万+

Problem A. Seventeen

Problem A. Seventeen Input file: standard input Output file: standard output Time limit: 1 second Memory limit: 256 megabytes Seventeen is a game where players try to construct an equation that evaluates to 17 using operators ±* and parentheses () and usin

qq_56167967的博客 424

Stata面板数据OLS回归分析实战指南

OLS回归作为计量经济学的核心分析方法,通过最小化残差平方和实现参数估计,广泛应用于经济学实证研究。其技术价值在于模型简洁、结果易于解释,特别适合处理面板数据中的复杂关系。在实际应用中,配合robust标准误能有效解决异方差问题,而固定效应模型则可控制个体特异性。本文以Stata软件为例,详细演示从数据导入、描述性统计到混合OLS和固定效应模型构建的全流程,重点解析面板数据特有的格式设定、模型选择标准以及结果呈现技巧,为经济学研究者提供可直接复用的分析框架。

weixin_29051811的博客 272

2017武汉大学校赛网络预选赛d题

Input file: standard input Output file: standard output Time limit: 1 second Memory limit: 512 mebibytes Every year, the ACM/ICPC team will hold many contests, some of them are training while othe

creatorx的博客 792

c语言串口编程详解

串口: 一种异步通信接口,通常用于低速数据传输。RS-232: 最常见的串口标准,定义了电气特性、连接器和信号线。UART: 通用异步收发传输器,是实现串口通信的硬件模块。通过以上内容,你应能够理解并实现C语言在Windows和Linux平台上的串口编程。希望这本手册能帮助你在实际项目中顺利进行串口通信开发。如果有任何疑问或需要进一步的帮助,请随时提问。

jkzyx123的博客 2227

eDP V1.4协议介绍

eDP的全称是Embedded DisplayPort嵌入式显示端口,主要应用与短距离系统内应用,例如手机、一体式台式机等。eDP V1.4b是基于DP V1.3标准制作完成,但因应用场景的不同,还是有很多区别。电压摆幅不同,eDP相对较低;eDP功耗相对较低;DP有线材和连接器的要求,eDP没有明确要求;AUX通道电路设计不同(相对DP取消了AC耦合电容和100KΩ/1MΩ的上下拉电阻):典型应用场景;

qflook的博客 4318

2017华中区邀请赛暨武汉大学校赛网络赛小结 + WOJ 642 Lost in WHU

截止目前最失败的一次比赛,奇耻大辱啊,orz……         卡在一些比较难写的题目里面,思路不清晰就在瞎敲代码,越改越死……         我们完全丢了一队的脸,甚至连二队三队都不如了,差点还进不了决赛,失眠难受了一整天……         事后还是那样,抛开这一切,许多问题变得明了起来,对于一些题目赛场上有猜测,后来发现也是对的,但因为陷入一道题而没去完善……         什

alpc_qleonardo 1032

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

2017武汉大学校赛 网络预选赛 简单题题解

补题目补了好几天,越发觉得自己是个菜鸡。。所以写个简单题的题解吧。。反正难的题目也不会做 除了A题题目贴过来都有格式问题。。所以不贴题目了最后会放题目链接 A. One car comes and one car goes Two cars from the East Station and the west Station started to drive toward each

fanesemyk的博客 1191

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

2017武汉大学校赛网络预选赛b题

Input file: standard input Output file: standard output Time limit: 1 second Memory limit: 512 mebibytes When Asuho was just a little girl, she has been loving stars, as there are so many romantic

creatorx的博客 1169

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

2017武汉大学校赛网络预选赛e题

Input file: standard input Output file: standard output Time limit: 1 second Memory limit: 512 mebibytes As one of the most beautiful campus in China, Wuhan University is around several hills, so

creatorx的博客 679

2017武大校赛网络预选赛C题 Divide by Six

DIVIDE BY SIX 无解时输出-1s而不是WTF 数据可能有前导零 Input file: standard input Output file: standard output Time limit: 1 second Memory limit: 512 mebibytes A positive integer number n is written on a b

Hi_jiaxinwei的博客 549

武汉大学校赛总结 + E题+F题

E.Your NP has been charged full这次比赛好难看,除了抢了一个签到题的一血,又是跟去年差不多的难看。 感觉主要还是练的不够多,一个一眼dp题没有看出来,还有一个找规律题找了一整场,从开局2分钟抢一血到出第二个题隔了200分钟(Galigaygay) 总结起来就是:还是不够熟练啊!!! E题 题意是一个游戏有n个回合,每次给出一组数,每组数里面有3个数字,ai,bi

WeYoungg的博客 679

27.12. standard input/output

27.12.1.xargs - build and execute command lines from standard input xargs命令是 给其他命令传递参数的一个过滤器,也是组合多个命令的一个工具 它擅长将标准输入数据转换成命令行参数,xargs能够处理管道或者stdin并将其转换成特定命令的命令参数. ...

weixin_33948416的博客 650

武大校赛网络赛总结

一场蛋疼的比赛,比赛时队友不好好交流,心态爆炸,比赛后我成了背锅侠。我开的俩题,一题数据出错,一题毒瘤。。。。 主要是写代码的习惯不同,我喜欢开工程,他们俩喜欢直接打开一个cpp就开撸。 于是我几乎没有上机时间。。。。。 锅甩完了,总结下自己获得的教训。 首先是自己学艺不精,如果我能熟练的使用模板,我就不会对着模板找bug找2小时,然后发现是自己参数写错了。。。、 其次是我沟通能力有问题

lifelike 513

Nearest Neighbor Search

## Nearest Neighbor Search ## Input file: standard input Output file: standard output Time limit: 1 second Memory limit: 1024 megabytes Bobo has a point p and a cube C in 3-di...

weixin_30316097的博客 219

2017WHU校赛color

树型DP

矮矮的夏祭的专栏 482

备战ACM校赛

今晚回顾了大一下学期计算智能的两道题,收获了一些东西。先将两道题目po上来。/*6581 Number Triangle    时间限制:500MS  内存限制:1000KDescription        7      3   8    8   1   0  2   7   4   44   5   2   6   5   (Figure 1)Figure 1 shows a number t...

cxm9194634的博客 435

武大校赛网络赛B题

B. Color链接:武大校赛网络赛B题 题意是给定一棵树然后每个节点可以染色,总共有m种颜色,给出一个01矩阵代表第i个点是否能染第j种颜色,然后问总共有多少种染色方法。 很明显的树形dp,可是比赛的时候没有时间去做,真的很可惜, dp[u][i]为第u个点染第i种颜色的方案数 dp[u][i] = dp[u][i] * ∑dp[v][j]

WeYoungg的博客 540

whu 1603 Minimum Sum(16武汉邀请赛网络赛)

题目链接:点这里!! 题意:给你n个数A[1] , A[2] .... A[n],从中选m个数 A[B[1]] , A[B[2]] ... A[B[m]] ( 1 使得sum abs( A[B[i]]-A[B[j]] ) when 1 数据范围:1 题解:易知,我们先给n个数排个序,然后就等价于从这个n个数选m个连续的数使得sum值最小。 我们直接一

Zsss的博客 387

2017武汉大学校赛网络预选赛c题

无解时输出-1s而不是WTF数据可能有前导零Input file: standard input Output file: standard output Time limit: 1 second Memory limit: 512 mebibytes A positive integer number n is written on a blackboard. It consists o

creatorx的博客 841
上一篇: 2017武汉大学校赛网络预选赛e题
下一篇: 2017武汉大学校赛网络预选赛d题
creatorx
博客等级 码龄10年 127粉丝 145原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值