hdu 6319 Problem A. Ascending Rating (2018 Multi-University Training Contest 3)

Posted jaydenouyang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hdu 6319 Problem A. Ascending Rating (2018 Multi-University Training Contest 3)相关的知识,希望对你有一定的参考价值。

 1 #include <stdio.h>
 2 #include <iostream>
 3 #include <cstdlib>
 4 #include <cmath>
 5 #include <string>
 6 #include <cstring>
 7 #include <algorithm>
 8 #include <stack>
 9 #include <queue>
10 #include <set>
11 #include <map>
12 #include <vector>
13 using namespace std;
14 typedef long long ll;
15 typedef unsigned long long ull;
16 
17 #define Faster ios::sync_with_stdio(false),cin.tie(0)
18 #define Read freopen("in.txt", "r", stdin),freopen("out.txt", "w", stdout)
19 const int INF = 0x3f3f3f3f;
20 const int maxn = 1e7 + 5;
21 
22 ll n, m, k, p, q, MOD, r;
23 ll a[maxn];
24 ll b[maxn];
25 
26 int main() 
27 {
28     Faster;
29     int T;
30     cin >> T;
31     while(T--){
32         cin >> n >> m >> k >> p >> q >> r >> MOD;
33         for(int i = 1;i <= n;i++){
34             if(i <= k){
35                 cin >> a[i];
36             }
37             else{
38                 a[i] = (p*a[i-1] + q*i + r)%MOD;
39             }
40         }
41         ll cnt, ans;
42         cnt = ans = 0;
43         for(int h = 1, t = 0, i = n;i >= 1;i--){
44             while(h <= t && a[b[t]] <= a[i]) t--;
45             b[++t] = i;
46             if(i+m-1 <= n){
47                 while(b[h] >= i+m) h++;
48                 ans += i^a[b[h]];
49                 cnt += i^(t-h+1);
50             }
51         }
52         cout << ans << " " << cnt << endl;
53     }
54     return 0;
55 }

 

以上是关于hdu 6319 Problem A. Ascending Rating (2018 Multi-University Training Contest 3)的主要内容,如果未能解决你的问题,请参考以下文章

hdu 6319 Problem A. Ascending Rating (2018 Multi-University Training Contest 3 A)

hdu 6319 Problem A. Ascending Rating (2018 Multi-University Training Contest 3)

2018 Multi-University Training Contest 3 1001 / hdu6319 Problem A. Ascending Rating 单调队列,思维

HDU 2018 Multi-University Training Contest 3 Problem A. Ascending Rating 单调队列优化

hdu-6319-单调队列

2018 多校3 hdu 6319 6322 6324 6330