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个数)的商, 于是没有规律的部分暴力解决, ...
随机推荐
- this inspection detects names that should resolved but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are sup
输入第一行代码:import logging;logging.basicConfig(level==logging.INFO) 提示:this inspection detects names tha ...
- numpy 性能提升
a = np.array([1,2,3,4,5,1,2,2,2])c = np.unique(a)print(c) 对于很大的稀疏矩阵,我们不能用a[a>0]去取大于0的元素,而应该使用np.w ...
- ubuntu12.04下编译Linux tina 2.1/android经验
用的是osboxes下的vdi. 编译Linux 1. 不能在root用户下操作 2. 执行 make kernel_menuconfig 报错,需要 apt-get install zlib1g z ...
- Python 第五阶段 学习记录之----ORM
ORM: orm英文全称object relational mapping,就是对象映射关系程序,简单来说我们类似python这种面向对象的程序来说一切皆对象,但是我们使用的数据库却都是关系型的,为了 ...
- 记录在tiny6410平台上采用4GSD卡来启动uboot和烧写nand flash uboot
下面这种方法是从网上转的 没有验证 环境:ubuntu 13.04一.首先制作sd启动盘: 插入SD卡 sudo dd iflag=dsync oflag=dsync if=tiny210v2- ...
- 2440 裸机学习 点亮LED
1.首先需要知道 led 是受哪一个gpio口控制 从上图可以看出,两个led灯是受GPF4 GPF5控制的,低电平有效. 2.怎么控制GPF4 GPF5 通过2440的芯片手册可以看出,需要设置GP ...
- 最新java学习路线:含阶段性java视频教程完整版
最新java学习路线:带阶段性java视频教程版本 第一阶段:Java基础 学习目标: 掌握基本语法.面向对象.常用类.正则.集合.Io流.多线程.Nio.网络编程.JDK新特性.函数式编程 知识点细 ...
- 启动docker容器时的Error response from daemon: devmapper: Error mounting: invalid argument. 错误解决
错误出现 在一台物理机重启后,以前创建的容器无法启动了.一启动,则会报出错误. [root@217TN1V ~]# docker start e7e Error response from daemo ...
- 虚拟主机、VPS、ECS云服务器 区别
在阿里云上买了个云服务器. ssh命令都没通,找服务端同事帮我看,说我买错了.应该买ECS. 1.虚拟主机 虚拟主机就是利用虚拟化的技术,将一台服务器划分出一定大小的空间,每个空间都给予单独的 FTP ...
- Python3 tkinter基础 Menu 添加菜单栏
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...