博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2018徐州网络赛H. Ryuji doesn't want to study
阅读量:4657 次
发布时间:2019-06-09

本文共 2722 字,大约阅读时间需要 9 分钟。

题目链接:

 

题解:

建立两个树状数组,第一个是,a[1]*n+a[2]*(n-1)....+a[n]*1;第二个是正常的a[1],a[2],a[3]...a[n]

#include "bits/stdc++.h"using namespace std;#define ll long longconst int MAXN=1e5+10;ll sum[MAXN],ans[MAXN];ll num[MAXN];ll n,q;int lowbit(int x){    return x&(-x);}void update(int i , ll x){    ll t=x*(n-i+1);    while(i<=n)    {        sum[i]+=x;        ans[i]+=t;        i+=lowbit(i);    }}ll query1(int x){    ll Sum=0;    while(x)    {        Sum+=sum[x];        x-=lowbit(x);    }    return Sum;}ll query2(int x){    ll Sum=0;    while(x)    {        Sum+=ans[x];        x-=lowbit(x);    }    return Sum;}int main(){    while(scanf("%lld%lld",&n,&q)!=EOF)    {        for(int i=1;i<=n;i++)        {            scanf("%lld",&num[i]);            update(i,num[i]);        }        while(q--)        {            int a,b,c;            scanf("%d",&a);            if(a==1)            {                scanf("%d%d",&b,&c);                ll A1=query1(c)-query1(b-1);                ll A2=query2(c)-query2(b-1);                printf("%lld\n",A2-A1*((n-b+1)-(c-b+1)));            } else            {                scanf("%d%d",&b,&c);                ll k=c-num[b];                num[b]=c;                update(b,k);            }        }    }    return 0;}

  

 

  •  262144K
 

Morgana is learning computer vision, and he likes cats, too. One day he wants to find the cat movement from a cat video. To do this, he extracts cat features in each frame. A cat feature is a two-dimension vector <xxyy>. If x_ixix_jxj and y_iyi = y_jyj, then <x_ixiy_iyi> <x_jxjy_jyj> are same features.

So if cat features are moving, we can think the cat is moving. If feature <aabb> is appeared in continuous frames, it will form features movement. For example, feature <aa , bb > is appeared in frame 2,3,4,7,82,3,4,7,8, then it forms two features movement 2-3-4234 and 7-878 .

Now given the features in each frames, the number of features may be different, Morgana wants to find the longest features movement.

Input

First line contains one integer T(1 \le T \le 10)T(1T10) , giving the test cases.

Then the first line of each cases contains one integer nn (number of frames),

In The next nn lines, each line contains one integer k_iki ( the number of features) and 2k_i2ki intergers describe k_ikifeatures in ith frame.(The first two integers describe the first feature, the 33rd and 44th integer describe the second feature, and so on).

In each test case the sum number of features NN will satisfy N \le 100000N100000 .

Output

For each cases, output one line with one integers represents the longest length of features movement.

样例输入复制

182 1 1 2 22 1 1 1 42 1 1 2 22 2 2 1 4001 1 11 1 1

样例输出复制

3

转载于:https://www.cnblogs.com/-xiangyang/p/9621968.html

你可能感兴趣的文章
IntelliJ idea学习资源
查看>>
Django Rest Framework -解析器
查看>>
ExtJs 分组表格控件----监听
查看>>
Hibernate二级缓存配置
查看>>
LoadRunner常用术语
查看>>
关于jedis2.4以上版本的连接池配置,及工具类
查看>>
记忆讲师石伟华微信公众号2017所有文章汇总(待更新)
查看>>
FactoryBean
查看>>
Coolite动态加载CheckboxGroup,无法在后台中获取
查看>>
C3P0连接池工具类使用
查看>>
SVN常用命令备注
查看>>
孩子教育
查看>>
解决Cacti监控图像断断续续问题
查看>>
结构体的传参理解成员的存储方式
查看>>
python 进程与线程(理论部分)
查看>>
什么是API
查看>>
[shiro学习笔记]第二节 shiro与web融合实现一个简单的授权认证
查看>>
强名称程序集(strong name assembly)——为程序集赋予强名称
查看>>
1028. List Sorting (25)
查看>>
BZOJ 1613: [Usaco2007 Jan]Running贝茜的晨练计划
查看>>