hdu多校第3场A.Ascending Rating
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的更多相关文章
- 杭电多校第三场 A Ascending Rating
Problem Description Before the start of contest, there are n ICPC contestants waiting in a long queu ...
- 2018 HDU多校第三场赛后补题
2018 HDU多校第三场赛后补题 从易到难来写吧,其中题意有些直接摘了Claris的,数据范围是就不标了. 如果需要可以去hdu题库里找.题号是6319 - 6331. L. Visual Cube ...
- 2018 HDU多校第四场赛后补题
2018 HDU多校第四场赛后补题 自己学校出的毒瘤场..吃枣药丸 hdu中的题号是6332 - 6343. K. Expression in Memories 题意: 判断一个简化版的算术表达式是否 ...
- hdu多校第三场
Problem D. Euler Function 思路:打表找找规律. #include<bits/stdc++.h> #define LL long long #define fi f ...
- HDU多校训练第一场 1012 Sequence
题目链接:acm.hdu.edu.cn/showproblem.php?pid=6589 题意:给出一个长度为n的数组,有m次操作,操作有3种1,2,3,问操作m次后的数组,输出i*a[i]的异或和 ...
- hdu多校第五场1005 (hdu6628) permutation 1 排列/康托展开/暴力
题意: 定义一个排列的差分为后一项减前一项之差构成的数列,求对于n个数的排列,差分的字典序第k小的那个,n<=20,k<=1e4. 题解: 暴力打表找一遍规律,会发现,对于n个数的排列,如 ...
- Harvest of Apples (HDU多校第四场 B) (HDU 6333 ) 莫队 + 组合数 + 逆元
题意大致是有n个苹果,问你最多拿走m个苹果有多少种拿法.题目非常简单,就是求C(n,0)+...+C(n,m)的组合数的和,但是询问足足有1e5个,然后n,m都是1e5的范围,直接暴力的话肯定时间炸到 ...
- 2014 HDU多校弟九场I题 不会DP也能水出来的简单DP题
听了ZWK大大的思路,就立马1A了 思路是这样的: 算最小GPA的时候,首先每个科目分配到69分(不足的话直接输出GPA 2),然后FOR循环下来使REMAIN POINT减少,每个科目的上限加到10 ...
- 2014 HDU多校弟八场H题 【找规律把】
看了解题报告,发现看不懂 QAQ 比较简单的解释是这样的: 可以先暴力下达标,然后会发现当前数 和 上一个数 的差值是一个 固定值, 而且等于当前数与i(第i个数)的商, 于是没有规律的部分暴力解决, ...
随机推荐
- (转)Linux vi 命令大全
进入vi的命令 vi filename :打开或新建文件,并将光标置于第一行首 vi +n filename :打开文件,并将光标置于第n行首 vi + filename :打开文件,并将光标置于最后 ...
- 经典的PHPer为什么被认为是草根?
PHPer是草根吗? 从PHP诞生之日起,PHP就开始在Web应用方面为广大的程序员服务.同时,作为针对Web开发量身定制的脚本语言,PHP一直秉承简单.开源的思想,这也使得PHP得以快速的发展,并且 ...
- openshift 容器云从入门到崩溃之七《数据持久化》
数据持久化常用的有两种: hostPath 挂载容器宿主机的本地文件夹,直接修改pod的配置 volumes: - hostPath: path: /data/logging-es type: '' ...
- (转载)Java多线程返回值处理
一.概述 到目前为止,我们已经能够声明并使一个线程任务运行起来了.但是遇到一个问题:现在定义的任务都没有任何返回值,那么加入我们希望一个任务运行结束后告诉我一个结果,该结果表名任务执行成功或失败,此时 ...
- GDI+案例
// // request_handler.cpp // ~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2017 Christopher M. Kohlho ...
- Sigleton bj
package com.bjsxt.base; class Sigleton{ private Sigleton(){}; private static Sigleton instance = new ...
- c#阿里云服务器发送邮件
public static void SendMailUse() { string host = "smtp.lotusest.com";// 邮件服务器smtp.163.com表 ...
- flask 定义数据库关系(一对多)
定义关系 在关系型数据库中,我们可以通过关系让不同表之间的字段建立联系.一般来说,定义关系需要两步,分别是创建外键和定义关系属性.在更复杂的多对多关系中,我们还需要定义关联表来管理关系.下面我们学习用 ...
- PhpStorm 2017破解
最新版PhpStorm 2017正式版改进了PHP 7支持,改进代码完成功能. PhpStorm 是最好的PHP开发工具,使用它进行PHP开发将会让你感觉到编程的乐趣. 快乐无极终于从oschina看 ...
- angular7 Rxjs 异步请求
Promise 和 RxJS 处理异步对比 Promise 处理异步: let promise = new Promise(resolve => { setTimeout(() => { ...