提交记录 16410


用户 题目 状态 得分 用时 内存 语言 代码长度
kai586123 test. 自定义测试 Accepted 100 210.733 ms 58648 KB C++11 1.41 KB
提交时间 评测时间
2021-08-06 19:48:39 2023-09-03 19:41:52
#include <bits/stdc++.h>

namespace GenHelper
{
    unsigned z1,z2,z3,z4,b;
    inline unsigned rand_()
    {
    b=((z1<<6)^z1)>>13;
    z1=((z1&4294967294U)<<18)^b;
    b=((z2<<2)^z2)>>27;
    z2=((z2&4294967288U)<<2)^b;
    b=((z3<<13)^z3)>>21;
    z3=((z3&4294967280U)<<7)^b;
    b=((z4<<3)^z4)>>12;
    z4=((z4&4294967168U)<<13)^b;
    return (z1^z2^z3^z4);
    }
}
inline void srand(unsigned x)
{using namespace GenHelper;
z1=x; z2=(~x)^0x233333333U; z3=x^0x1234598766U; z4=(~x)+51;}
inline int read()
{
    using namespace GenHelper;
    int a=rand_()&32767;
    int b=rand_()&32767;
    return a*32768+b;
}

const int N = 2e7 + 233;
int A[N], ls[N], rs[N], stk[N], root;

inline void prework(unsigned n) {
int top = 0;
  for (unsigned i = 1; i <= n; ++i) {
    while (top && A[stk[top]] <= A[i])
      ls[i] = stk[top--];
    rs[stk[top]] = i;
    stk[++top] = i;
  }
  root = stk[1];
}

inline unsigned long long query(int l, int r) {
  for (int x = root; ; x = r < x ? ls[x] : rs[x])
    if (l <= x && r >= x)
      return A[x];
}

int main() {
  unsigned n, m; unsigned s;
n = 5000000, m = 5000000, s = 233;
  std::cin >> n >> m >> s;
  srand(s);
  for (unsigned i = 1; i <= n; ++i)
    A[i] = read();
  prework(n);
  unsigned long long ans = 0;
  for (unsigned i = 1; i <= m; ++i) {
    int l = read() % n + 1, r = read() % n + 1;
    ans += query(l <= r ? l : r, l <= r ? r : l);
  }
  std::cout << ans << std::endl;
  return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #1210.733 ms57 MB + 280 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2026-03-19 06:20:12 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠