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. 002-红黑树【B-树】、二叉查找树

    一.引述-二叉查找树 红黑树(Red Black Tree) 一种特殊的二叉查找树.故先查看二叉查找树 二叉查找树特性:左字数上所有的节点的值都小于或等于他的根节点上的值 右子树上所有节点的值均大于或 ...

  2. Tomcat服务安全加固

    Tomcat服务默认启用了管理后台功能,使用该后台可直接上传 war 文件包对站点进行部署和管理.由于运维人员的疏忽,可能导致管理后台存在空口令或者弱口令的漏洞,使得黑客或者不法分子可以利用该漏洞直接 ...

  3. 关于Java8 Stream流的利与弊 Java初学者,大神勿喷

    题目需求: 1:第一个队伍只要名字为3个字成员的姓名,存储到新集合 2:第一个队伍筛选之后只要前3人:存储到一个新集合 3:第2个队伍只要姓张的成员姓名:存储到一个新集合 4:第2个队伍不要前2人,存 ...

  4. C#-----中使用using详解

    1.using指令 using + 命名空间名字 例:using System;        using System.Data; 2.using语句 定义一个范围,在范围结束时处理对象,出了这个范 ...

  5. py-faster-rcnn代码

    1. 对proposal层NMS的解释,很清晰 注意第18~20行是拿一个数(x1)和array(x1[ [0,2,3] ])去比:

  6. IDEA中文出现乱码解决(转)

    转自:http://lcl088005.iteye.com/blog/2284696 我是个idea的忠实用户,新公司的项目都是用eclipse做的,通过svn拉下代码后发现,注释的内容里,中文内容都 ...

  7. 【转】AI类人工智能产品经理的丛林法则

    本文转载自:https://blog.csdn.net/buptgshengod/article/details/77030338 AI是大家都很关注的领域,然而对于大部分想要入行的同学来讲,AI的算 ...

  8. 关于使用MUI框架ashx获取值的问题

    前台如有 var value = '<%= value%>';  后台在使用  Params["value"]的时候会出现重复(例:value,value).

  9. MySQL驱动和数据库字符集设置不搭配

    刚才控制台又报这个错,这是代表MySQL驱动和数据库字符集设置不搭配: 错误: "...Initial client character set can be forced via the ...

  10. Python sqlalchemy orm 常用操作

    增add # 创建表1 # 注:高级封装 import sqlalchemy # 调用链接数据库 from sqlalchemy import create_engine # 调用基类Base fro ...