CodeForces 1284 B. New Year and Ascent Sequence

AUTOSAR OS AUTOSAR OS总共包含以下。Core中基本对象关系如上图所示,以单核为例,。每个基本对象必须从属于某个OS Application,否则会出现错误。同时OS Application可分为Trusted与Not Trusted这两种类型。 阅读详情

A sequence a=[a1,a2,…,al] of length l has an ascent if there exists a pair of indices (i,j) such that 1≤i<j≤l and ai<aj. For example, the sequence [0,2,0,2,0] has an ascent because of the pair (1,4), but the sequence [4,3,3,3,1] doesn’t have an ascent.

Let’s call a concatenation of sequences p and q the sequence that is obtained by writing down sequences p and q one right after another without changing the order. For example, the concatenation of the [0,2,0,2,0] and [4,3,3,3,1] is the sequence [0,2,0,2,0,4,3,3,3,1]. The concatenation of sequences p and q is denoted as p+q.

Gyeonggeun thinks that sequences with ascents bring luck. Therefore, he wants to make many such sequences for the new year. Gyeonggeun has n sequences s1,s2,…,sn which may have different lengths.

Gyeonggeun will consider all n2 pairs of sequences sx and sy (1≤x,y≤n), and will check if its concatenation sx+sy has an ascent. Note that he may select the same sequence twice, and the order of selection matters.

Please count the number of pairs (x,y) of sequences s1,s2,…,sn whose concatenation sx+sy contains an ascent.

Input
The first line contains the number n (1≤n≤100000) denoting the number of sequences.

The next n lines contain the number li (1≤li) denoting the length of si, followed by li integers si,1,si,2,…,si,li (0≤si,j≤106) denoting the sequence si.

It is guaranteed that the sum of all li does not exceed 100000.

Output
Print a single integer, the number of pairs of sequences whose concatenation has an ascent.

Examples
input
5
1 1
1 1
1 2
1 4
1 3
output
9
input
3
4 2 0 2 0
6 9 9 8 8 7 7
1 6
output
7
input
10
3 62 24 39
1 17
1 99
1 60
1 64
1 30
2 79 29
2 20 73
2 85 37
1 100
output
72
Note
For the first example, the following 9 arrays have an ascent: [1,2],[1,2],[1,3],[1,3],[1,4],[1,4],[2,3],[2,4],[3,4]. Arrays with the same contents are counted as their occurences.

题意
给你n个li长度的串,问有多少个串结合满足结合后的串不是递减序列。

思路
我们首先模拟子段的结合,我们发现就只有两种可能:
本身可以的,他结合后也肯定是
本身不可以的,结合后与另一个本身不可以的,并且最大值小于之前最小的,这个是不可以的。
我们用数组记录每个串的max,min,他本身可以吗。
然后用前缀和来记录比这个数小的有几个,这样可以把o(N^2)降到o(N)

代码

#include <bits/stdc++.h>
typedef long long ll;
const ll mod = 998244353;
using namespace std;
namespace fastIO {
    inline void input(int& res) {
        char c = getchar();res = 0;int f = 1;
        while (!isdigit(c)) { f ^= c == '-'; c = getchar(); }
        while (isdigit(c)) { res = (res << 3) + (res << 1) + (c ^ 48);c = getchar(); }
        res = f ? res : -res;
    }
    inline ll qpow(ll a, ll b) {
        ll ans = 1, base = a;
        while (b) {
            if (b & 1) ans = (ans * base % mod +mod )%mod;
            base = (base * base % mod + mod)%mod;
            b >>= 1;
        }
        return ans;
    }
}
using namespace fastIO;
const int N = 1e5+5;
int Case,n,l;
int a[N],minn[N],f[N],maxx[N],vis[N*10],pre[N*10];
int main(){
	Case=1;
	//input(Case);
	while(Case--){
		input(n);
		ll ans = 0;
		for(int i=1;i<=n;i++){
			input(l);
			bool flag = false;
			int mn = 0x3f3f3f3f,mx = 0;
			for(int j=1;j<=l;j++){
				input(a[j]);
				if(j>=2&&a[j]>a[j-1]) flag = true;
				mn = min(mn,a[j]);
				mx = max(mx,a[j]);
			}
			if(flag) f[i]=1;
			else vis[mx]++;
			maxx[i]=mx;
			minn[i]=mn;
			
		}
		pre[0]=vis[0];
		for(int i=1;i<=1e6;i++){
			pre[i] = pre[i-1] + vis[i];
		}
		for(int i = 1;i<=n;i++){
			//cout<<f[i]<<" "<<ans<<" "<<pre[minn[i]]<<" "<<minn[i]<<endl;
			ans += n;
			if(!f[i]) ans -= pre[minn[i]];
			
		}
		printf("%lld\n",ans);
	}
	return 0;
}
/*
5
1 1
1 1
1 2
1 4
1 3
*/
[QMT量化交易小白入门]-九十五、多因子选股和趋势择时股票量化交易策略,年化收益率40.61% 本策略采用“双层过滤”机制:第一层基于多维度财务指标进行股票池筛选(多因子选股),第二层运用均线系统和MACD指标实施动态择时(趋势跟踪)。这种设计既保证了组合的质量下限,又能灵活应对市场波动。因子配置科学性:涵盖估值、成长、盈利、动量四大类因子风险控制精细化:设置动态止损与仓位管理机制信号验证严格性:多重条件交叉验证提升胜率。 阅读详情

相关推荐

《数据结构》04-树4 是否同一棵二叉搜索树

题目 给定一个插入序列就可以唯一确定一棵二叉搜索树。然而,一棵给定的二叉搜索树却可以由多种不同的插入序列得到。例如分别按照序列{2, 1, 3}和{2, 3, 1}插入初始为空的二叉搜索树,都得到一样的结果。于是对于输入的各种插入序列,你需要判断它们是否能生成一样的二叉搜索树。 输入格式: 输入包含若干组测试数据。每组数据的第1行给出两个正整数N (≤10)和L,分别是每个序列插入元素的个数和需要...

叫我皮卡丘 2013

CF1284B New Year and Ascent Sequence(数字串,思维)

题目链接: New Year and Ascent Sequence - 洛谷 思路: 题目说了,只要两者拼起来的序列中有递增子序列,就是符合题意的序列。我们可以反向考虑:计算所有不符合题意的序列数量,然后用n*n减去这个数,就是最终答案。 首先,内部有递增子序列的串,不管和谁拼起来都是满足题意的,所以不考虑这些串。我们只记录内部没有递增子序列的串的最大值和最小值,然后枚举每个记录了的串,记录不能接在它后面的串的数量,mn[ i ] >= mx[ j ]说明 j 不能接在 i 的后面。 .

bunny_1024的博客 212

Q学习(Q-learning)入门小例子及python实现

一、从马尔科夫过程到Q学习 # 有一定基础的读者可以直接看第二部分 Q学习(Q-learning)算法是一种与模型无关的强化学习算法,以马尔科夫决策过程(Markov Decision Processes, MDPs)为理论基础。 标准的马尔科夫决策过程可以用一个五元组<S,A,P,R,γ>表示,其中: S是一个离散有界的状态空间; A是一个离散的动作空间; P为状态转...

wlm_py的博客 4万+

【数据结构 + 二分】Codeforce 1284B New Year and Ascent Sequence

继续撸题! 一、题目大意 题目的大致意思是,给你 n 个数字序列,要求你对其中的序列进行任意组合,求组合后满足有一个上升的条件的组合数有多少种(可以自身和自身组合) 关于有一个上升的条件,就是在序列中存在一对数ai,aj,如果 i > j 的话,那么,ai > aj,注意,存在一对即可。 二、题目思路以及AC代码 这题大体思路如下,其实就考察数据结构建立以及二分,当然我会后面证明它...

Johnson的博客 730

反激开关电源变压器设计实例讲解(定明芳)

内容来自《反激变压器的设计》(定明芳主讲)。 定名芳老师主要讲了10步,最后应该还有一步,线径的选择已经绕制方式。这里进行了记录整理,把一些公式来源进行了推导。所有的设计都是基于理论计算。 1.确定电源规格 2.确定工作频率和最大占空比 3.计算匝比(利用伏秒平衡原则) 此处插入解释一下伏秒平衡,根源是磁通量平衡。该原则可以用来检查MOS管耐压是否够。 4.计算初级线圈峰值电流 基于CCM模式计算的。ip1是开关管要关闭时的峰值电流,ip2是开关管开始导通时的起始电流。因为时CCM模式,所以,ip

ydgd118的博客 5万+

纯电动汽车/飞机动力电池系统解析

如图16所示,先看均衡前,某个模块已达到放电终止电压(下限保护电压),其他模块还有一定的电量,这时不能继续放电;(1)慢充预充电回路,如图20所示:交流充电桩→车载充电机→高压+→预充继电器触点→预充电阻→电池模组→维修开关(内有熔断器)→电池模组→电流传感器→主负继电器触点→高压-→车载充电机→交流充电桩。辅助元器件如图8所示,包括动力电池系统内部的电子电器:主正继电器、预充继电器、预充电阻、主负继电器、高压熔断器、加热继电器、加热熔断器、电流传感器、高压插座、低压插座,还包括密封条、绝缘材料等。

boboelec的博客 4128

Codeforces Hello 2020 B.New Year and Ascent Sequence

B. New Year and Ascent Sequence time limit per test: 2 seconds memory limit per test: 1024 megabytes input: standard input output: standard output A sequence a=[a1,a2,…,al] of length l has an ascent i...

产品的博客 548

[南大ICS-PA2]PA2 - 简单复杂的机器:冯诺依曼计算机系统

mips32和riscv32的指令长度只有32位, 因此它们不能像x86那样, 把C代码中的32位常数直接编码到一条指令中. 思考一下, mips32和riscv32应该如何解决这个问题?加载立即数到寄存器的高20位,然后便可以是哟给你标准的立即指令来创建32位常量。在程序分析领域中,静态指令是指程序代码中的指令,动态指令是指程序运行过程中的指令,例如对于一下指令序列。位域,在小端机器上,先定义的在每个字节的低位,后定义的在每个字节的高位。,这是处理非法指令的宏,其定义在。指令,而下一条动态指令则是。

qq_42474104的博客 930

[codeforces 1284B] New Year and Ascent Sequence 容斥原理+桶排序+前缀和+滚动数组

[codeforces 1284B] New Year and Ascent Sequence 容斥原理+桶排序+前缀和+滚动数组 总目录详见https://blog.csdn.net/mrcrack/article/details/103564004 在线测评地址http://codeforces.com/contest/1284/problem/B Problem Lang ...

mrcrack的博客 548

【人工智能】RAG如何根据实际需求选择和进行文档解析(如 PDF、Word、TXT、网页等)?

文档解析的核心在于根据解析目标、文档类型和处理量选择合适工具。PDF、Word、TXT和网页各有特性:PDF需区分可编辑与扫描版,Word需处理结构化内容,TXT简单但需注意编码,网页需应对动态内容。解析场景包括提取纯文本、结构化数据、保留格式和批量处理。非技术用户可借助工具如Adobe Acrobat、WPS和在线OCR,技术用户可通过编程实现自动化。通用流程为:明确目标、分析文档属性、选择工具并测试优化。核心是“工具适配需求”,无需追求万能方案。

奶爸的编程之路,也就一周冷个三天 514

FineReport实战-- 国内外各地区销售数据分析 多个图表联动

进行国内外各地区业务员销售数据分析是一项复杂但极具价值的任务,它可以帮助企业了解不同市场的表现,并据此调整销售策略以提高整体绩效。实现功能:同一个报表里面多个图表联动问题。

Davina_yu的博客 1206

Hello 2020 B.New Year and Ascent Sequence

Hello 2020 B.New Year and Ascent Sequence A sequence a=[a1,a2,…,al] of length l has an ascent if there exists a pair of indices (i,j) such that 1≤i<j≤l and ai<aj. For example, the sequence [0,2,...

旺崽的博客 3603

数据结构之博弈树搜索(深度优先搜索)

数据结构之博弈树搜索(深度优先搜索)

LucianaiB的博客 1533

CodeForces - 1284B New Year and Ascent Sequence(乱搞)

题目链接:点击查看 题目大意:规定一个数列中在不改变内部顺序的前提下,至少存在着一组(i,j)满足: i<j a[i]<a[j] 就称该数列为上升数列,现在给出n组数列,每两组数列可以进行拼接操作,即Sx={1,2,3},Sy={4,5,6},Sx+Sy={1,2,3,4,5,6},Sy+Sx={4,5,6,1,2,3},现在问n^2种组合可以组成多少个上升数列 题目分析:挺综...

Falcon的博客 705

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

CF1284B·New Year and Ascent Sequence

Codeforces #Hello 2020 B New Year and Ascent Sequence 模拟

樱狸✨愿携清风归来处 482

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

B. New Year and Ascent Sequence

链接:https://codeforces.com/contest/1284/problem/B A sequencea=[a1,a2,…,al]a=[a1,a2,…,al]of lengthllhas anascentif there exists a pair of indices(i,j)(i,j)such that1≤i<j≤l1≤i<j≤landai&...

Luoriliming的博客 407

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

Hello 2020 B. New Year and Ascent Sequence

链接 https://codeforces.com/contest/1284/problem/C 题意 定义一个长度为 lll 的序列中 aaa 存在 ai<aj(1≤i≤j≤l)a_i<a_j(1\le i\le j\le l)ai​<aj​(1≤i≤j≤l) 为合法序列 对于序列 ppp 和序列 qqq,若 p+qp+qp+q 为合法序列,则为有效组合 问 nnn 个序列中有多少种有效组合 思路 当 p+qp+qp+q 为无效组合只有一种情况:ppp 和 qqq 本身都不是合法序列且

c4Lnn 的 CSDN 博客 153

B - New Year and Ascent Sequence(思维+细节!)

https://codeforces.com/contest/1284/problem/B 思路: 换到值上去.. 开始跑了个树状数组发现样例3怎么都不对..现在也不知道为啥.. 然后改成前缀一直wa9.. 不知道哪里的边界问题.. 然后都+1就过了(总之最近心态各种炸裂+水逆 #include<iostream> #include<vector> #include<queue> #include<cstring> #include<

代码笔记本 191

Codeforces Hello 2020 B. New Year and Ascent Sequence(二分查找)

题目链接:https://codeforc.es/contest/1284/problem/B A sequence a=[a1,a2,…,al] of length l has an ascent if there exists a pair of indices (i,j) such that 1≤i<j≤l and ai<aj. For example, the sequence [0,2,0,2,0] has an ascent because of the pair (1,4), bu

Sankkl1的博客 177

1284E - New Year and Castle Construction(极角排序)

http://codeforces.com/problemset/problem/1284/E 题意: 给出n个点(n<=2500),问每个点被多少个四边形严格包含,只需要输出所有的和即可。(4个点组成的不同四边形算一种,保证不出现三点共线) 解析: 点被多少个包含,乍一听就是个极角排序问题。以前做过被三角形包含的问题(https://jkchen.blog.csdn.net/article...

QAQ 541

New Year and Ascent Sequence(二分)

题目传送门 A sequence a=[a1,a2,…,al] of length l has an ascent if there exists a pair of indices (i,j) such that 1≤i<j≤l and ai<aj. For example, the sequence [0,2,0,2,0] has an ascent because of the pair (1,4), but the sequence [4,3,3,3,1] doesn’t have an

s1050712899的博客 263

New Year and Ascent Sequence cf1284B two point

B. New Year and Ascent Sequence A sequencea=[a1,a2,…,al]a=[a1,a2,…,al]of lengthllhas anascentif there exists a pair of indices(i,j)(i,j)such that1≤i<j≤l1≤i<j≤landai<ajai<aj. ...

yhb的博客 398

codeforce Hello 2020

文章目录A. New Year and Naming题目题意思路代码B. New Year and Ascent Sequence题目题意思路代码 A. New Year and Naming 题目 Happy new year! The year 2020 is also known as Year Gyeongja (경자년, gyeongja-nyeon) in Korea. Where ...

一只小蒟蒻的博客 798

B. New Year and Ascent Sequence----思维/水

A sequence a=[a1,a2,…,al] of length l has an ascent if there exists a pair of indices (i,j) such that 1≤i<j≤l and ai<aj. For example, the sequence [0,2,0,2,0] has an ascent because of the pair (...

qq_43690454的博客 470

CF Hello 2020 B New Year and Ascent Sequence

CF Hello 2020 B New Year and Ascent Sequence 题意: 给你n个数组,两两之间进行有序拼接,要求判断拼接后的数组是否是上升的,判断条件是是否存在这样的整数对 1≤i<j≤l 并且ai<aj。 思路: 用两个数组分别记录下每个数组的最大值和最小值,然后把最大值进行排序。每次取每个数组中的最小值到所有数组中的最大值中找有多少个数比它大。有的特殊情...

江小举的博客 827

Hello 2020 B - New Year and Ascent Sequence (容斥)

???? ???? ???? 1,需要寻找的方案出现:满足 A条件 or B条件 均可计算在内, 而有可能存在方案符合多个(A and B)条件,(可能会计算重复) 这种情况下考虑容斥 2,求满足最大值小于最小值的对数,利用单调性, 如果最大值maxv,最小值minv集合有序,i<j 如果某minv[k]>=maxv[j] 则 一定存在minv[k]>maxv[i],(即当前数组不符合条件的对数是...

欢迎光临 我的心 305
上一篇: Codeforces 1283 E. New Year Parties
下一篇: CodeForces 1284 C. New Year and Permutation
Elige?
博客等级 码龄13年 16粉丝 68原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值