Problem A. Ascending Rating

Time Limit: / MS (Java/Others)    Memory Limit: / K (Java/Others)
Total Submission(s): Accepted Submission(s): Problem Description
Before the start of contest, there are n ICPC contestants waiting in a long queue. They are labeled by to n from left to right. It can be easily found that the i-th contestant's QodeForces rating is ai.
Little Q, the coach of Quailty Normal University, is bored to just watch them waiting in the queue. He starts to compare the rating of the contestants. He will pick a continous interval with length m, say [l,l+m−], and then inspect each contestant from left to right. Initially, he will write down two numbers maxrating=− and count=. Everytime he meets a contestant k with strictly higher rating than maxrating, he will change maxrating to ak and count to count+.
Little T is also a coach waiting for the contest. He knows Little Q is not good at counting, so he is wondering what are the correct final value of maxrating and count. Please write a program to figure out the answer. Input
The first line of the input contains an integer T(≤T≤), denoting the number of test cases.
In each test case, there are integers n,m,k,p,q,r,MOD(≤m,k≤n≤,≤p,q,r,MOD≤) in the first line, denoting the number of contestants, the length of interval, and the parameters k,p,q,r,MOD.
In the next line, there are k integers a1,a2,...,ak(≤ai≤), denoting the rating of the first k contestants.
To reduce the large input, we will use the following generator. The numbers p,q,r and MOD are given initially. The values ai(k<i≤n) are then produced as follows :
ai=(p×ai−+q×i+r)modMOD It is guaranteed that ∑n≤× and ∑k≤×. Output
Since the output file may be very large, let's denote maxratingi and counti as the result of interval [i,i+m−1].
For each test case, you need to print a single line containing two integers A and B, where :
AB==∑i=1n−m+(maxratingi⊕i)∑i=1n−m+(counti⊕i) Note that ``⊕'' denotes binary XOR operation. Sample Input Sample Output Source
Multi-University Training Contest Recommend
chendu | We have carefully selected several similar problems for you:

题意:一个长度为n的序列,输入给出来k个数,剩下的n-k+1个数由递推公式得出, 求出所有区间[i,i+m+1]的最大值异或 i 的和和在这一个区间最大值变化次数异或 i 的和

双端队列:单调队列倒着跑最大值,count=最大值变化的次数;

#include <cstdio>
#include <cstring>
#include <iostream>
//#include <algorithm>
#include <vector>
using namespace std;
#define ll long long
//#define mod 998244353
const int manx=1e7+;
int n,m,k,p,q,r,mod,a[manx],que[manx];
int main()
{
int T;
scanf("%d",&T);
while(T--) {
scanf("%d %d %d %d %d %d %d",&n,&m,&k,&p,&q,&r,&mod);
for(int i = ; i <= k; i++) scanf("%d",&a[i]);
for(int i = k + ; i <= n; i++) {
a[i]=(1LL * p * a[i-] + 1LL * q * i + 1LL * r) % mod;
}
int s=,t=;
ll max=;
ll cot=;
for(int i=n;i>;i--)
{
while(s<t&&a[que[t-]]<=a[i]) t--;
que[t++]=i;
while(que[s]>i+m-)
s++;
if(i<=n-m+)
{ max+=(ll)i^(ll)a[que[s]];
cot+=(ll)i^(ll)(t-s);
} }
printf("%lld %lld\n",max,cot); }
return ;
}

hdu多校第3场A.Ascending Rating的更多相关文章

  1. 杭电多校第三场 A Ascending Rating

    Problem Description Before the start of contest, there are n ICPC contestants waiting in a long queu ...

  2. 2018 HDU多校第三场赛后补题

    2018 HDU多校第三场赛后补题 从易到难来写吧,其中题意有些直接摘了Claris的,数据范围是就不标了. 如果需要可以去hdu题库里找.题号是6319 - 6331. L. Visual Cube ...

  3. 2018 HDU多校第四场赛后补题

    2018 HDU多校第四场赛后补题 自己学校出的毒瘤场..吃枣药丸 hdu中的题号是6332 - 6343. K. Expression in Memories 题意: 判断一个简化版的算术表达式是否 ...

  4. hdu多校第三场

    Problem D. Euler Function 思路:打表找找规律. #include<bits/stdc++.h> #define LL long long #define fi f ...

  5. HDU多校训练第一场 1012 Sequence

    题目链接:acm.hdu.edu.cn/showproblem.php?pid=6589 题意:给出一个长度为n的数组,有m次操作,操作有3种1,2,3,问操作m次后的数组,输出i*a[i]的异或和 ...

  6. hdu多校第五场1005 (hdu6628) permutation 1 排列/康托展开/暴力

    题意: 定义一个排列的差分为后一项减前一项之差构成的数列,求对于n个数的排列,差分的字典序第k小的那个,n<=20,k<=1e4. 题解: 暴力打表找一遍规律,会发现,对于n个数的排列,如 ...

  7. Harvest of Apples (HDU多校第四场 B) (HDU 6333 ) 莫队 + 组合数 + 逆元

    题意大致是有n个苹果,问你最多拿走m个苹果有多少种拿法.题目非常简单,就是求C(n,0)+...+C(n,m)的组合数的和,但是询问足足有1e5个,然后n,m都是1e5的范围,直接暴力的话肯定时间炸到 ...

  8. 2014 HDU多校弟九场I题 不会DP也能水出来的简单DP题

    听了ZWK大大的思路,就立马1A了 思路是这样的: 算最小GPA的时候,首先每个科目分配到69分(不足的话直接输出GPA 2),然后FOR循环下来使REMAIN POINT减少,每个科目的上限加到10 ...

  9. 2014 HDU多校弟八场H题 【找规律把】

    看了解题报告,发现看不懂 QAQ 比较简单的解释是这样的: 可以先暴力下达标,然后会发现当前数 和 上一个数 的差值是一个 固定值, 而且等于当前数与i(第i个数)的商, 于是没有规律的部分暴力解决, ...

随机推荐

  1. 虚拟机VM三种网络连接方式说明

  2. 线段树 HDU-1166 敌兵布阵

    敌兵布阵是一个线段树典题,题目如下(点此查看题目出处): Problem Description C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了.A国 ...

  3. 20190403vim编辑器week1_day3

    vi编辑器 作用:编辑文本文件中的内容的工具 命令历史 末行模式中,以:和/开头的命令都有历史纪录,可以首先键入:或/然后按上下箭头来选择某个历史命令. 启动vim 在命令行窗口中输入以下命令即可 v ...

  4. 使用solr进行配置文件

    我现在使用的是一个已经搭建好的solr环境下进行的测试: 第一步,需要配置solrhome中的一个配置文件schema.xml 配置内容如下,上面配置的是IK分词器,下面是配置完成的域. 因为我在这个 ...

  5. 使用 mysqladmin debug 查看死锁信息

    使用 mysqladmin debug 查看死锁信息 mysqladmin -S /mysql/data/mysql.sock debug 然后在error日志中,会看到: 11 lock struc ...

  6. Html textarea 标签

    Html textarea 标签 </body> </html> <!-- textarea 标签输入多行文本框,name="xxx"标识后端获取名称 ...

  7. dubbo多网卡时,服务提供者的错误IP注册到注册中心导致消费端连接不上

    使用了虚拟机之后,启动了dubbo服务提供者应用,又连了正式环境的注册中心: 一旦dubbo获取的ip错误后, 这种情况即使提供者服务停掉,目前dubbo没有能力清除这类错误的提供者: (需要修改源码 ...

  8. 尚硅谷面试第一季-18ES与Solr的区别

    背景:它们都是基于Lucene搜索服务器基础之上开发,一款优秀的,高性能的企业级搜索服务器.[是因为他们都是基于分词技术构建的倒排索引的方式进行查询] 开发语言:Java语言开发 诞生时间:Solr ...

  9. DRF中的APIView源码分析

    首先写一个简单的drf接口 from rest_framework.views import APIView from rest_framework.response import Response ...

  10. 7th,Python基础4——迭代器、生成器、装饰器、Json&pickle数据序列化、软件目录结构规范

    1.列表生成式,迭代器&生成器 要求把列表[0,1,2,3,4,5,6,7,8,9]里面的每个值都加1,如何实现? 匿名函数实现: a = map(lambda x:x+1, a) for i ...