题意

题目链接

Sol

ODT板子题。就是用set维护连续段的大暴力。。

然鹅我抄的板子本题RE提交AC??。。

具体来说,用50 50 658073485 946088556这个数据测试下面的代码,然后在79行停住,看一下bg和i的值会发生神奇的事情。。

问题已解决,确实是那位博主写错了, 只要把split(l)和split(r + 1)反过来就行了

#include<bits/stdc++.h>
#define LL long long
#define int long long
#define sit set<Node>::iterator
#define fi first
#define se second
using namespace std;
const int MOD = 1e9 + 7, MAXN = 1e6 + 10;
inline int read() {
char c = getchar(); int x = 0, f = 1;
while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return x * f;
}
int N, M, mod;
template<typename A, typename B> inline int mul(A x, B y) {
return 1ll * x * y % mod;
}
template<typename A, typename B> inline void add2(A &x, B y) {
x = (x + y % mod);
}
LL seed, vmax;
int a[MAXN];
int rnd() {
int ret = seed;
seed = (seed * 7 + 13) % MOD;
return ret;
}
struct Node {
int l, r;
mutable LL v;
bool operator < (const Node &rhs) const {
return l < rhs.l;
}
};
set<Node> s;
sit split(int p) {
auto pos = s.lower_bound({p});
if(pos != s.end() && pos->l == p) return pos;
pos--;
int L = pos->l, R = pos->r, V = pos->v;
s.erase(pos);
s.insert({L, p - 1, V});
return s.insert({p, R, V}).fi;
}
void Add(int l, int r, int val) {
auto bg = split(l), ed = split(r + 1);
for(auto i = bg; i != ed; i++) i->v += val;
}
void Mem(int l, int r, int val) {
for(int i = l; i <= r; i++) a[i] = val;
auto bg = split(l), ed = split(r + 1);
s.erase(bg, ed);
s.insert({l, r, val});
}
int rak(int l, int r, int x) {
vector<pair<LL, int>> v;
auto bg = split(l), ed = split(r + 1);
for(auto i = bg; i != ed; i++)
v.push_back({i->v, i->r - i->l + 1}); sort(v.begin(), v.end());
for(auto it = v.begin(); it != v.end(); it++) {
x -= it -> se;
if(x <= 0) return it -> fi;
}
assert(0);
}
int fp(int a, int p) {
int base = 1; a %= mod;
while(p) {
if(p & 1) base = 1ll * base * a % mod;
a = 1ll * a * a % mod; p >>= 1;
}
return base;
}
int po(int l, int r, int x) {
if(l == 6 && r == 7) {
puts("G");
}
auto bg = split(l);
printf("%d %d %d %d\n", bg->l, bg->r, bg->v);
auto ed = split(r + 1);
int ans = 0;
for(sit i = bg; i != ed; i++) {
printf("%d %d %d %d\n", i->l, i->r, i->v);
ans = (ans + (i->r - i->l + 1) * fp(i->v, x) % mod) % mod;
}
return ans;
}
signed main() {
N = read(); M = read(); seed = read(); vmax = read();
for(int i = 1; i <= N; i++) a[i] = (rnd() % vmax) + 1, s.insert({i, i, a[i]});
s.insert({N + 1, N + 1, 0});
for(int i = 1; i <= M; i++) {
int op = (rnd() % 4) + 1; int l = (rnd() % N) + 1; int r = (rnd() % N) + 1, x = -1;
if(l > r) swap(l, r); if(op == 3) x = (rnd() % (r - l + 1)) + 1;
else x = (rnd() % vmax) + 1;
if(op == 4) mod = (rnd() % vmax) + 1;
if(op == 1) Add(l, r, x);
else if(op == 2) Mem(l, r, x);
else if(op == 3) cout << rak(l, r, x) << '\n';
else cout << po(l, r, x) << '\n';
}
return 0;
}
/*
50 50 658073485 946088556
*/

cf896C. Willem, Chtholly and Seniorious(ODT)的更多相关文章

  1. 【ODT】cf896C - Willem, Chtholly and Seniorious

    仿佛没用过std::set Seniorious has n pieces of talisman. Willem puts them in a line, the i-th of which is ...

  2. Codeforces Round #449 (Div. 1) Willem, Chtholly and Seniorious (ODT维护)

    题意 给你一个长为 \(n\) 的序列 \(a_i\) 需要支持四个操作. \(1~l~r~x:\) 把 \(i \in [l, r]\) 的 \(a_i\) 加 \(x\) . \(2~l~r~x: ...

  3. [CF896C]Willem, Chtholly and Seniorious(珂朵莉树)

    https://www.cnblogs.com/WAMonster/p/10181214.html 主要用于支持含有较难维护的区间操作与查询的问题,要求其中区间赋值操作(assign())是纯随机的. ...

  4. [CF896C]Willem, Chtholly and Seniorious

    题目大意:有$n$个数,有$m$次$4$种操作: l r x :将$[l,r]$区间所有数加上$x$ l r x :将$[l,r]$区间所有数变成$x$ l r k :输出$[l,r]$区间第$k$大 ...

  5. CF896C Willem, Chtholly and Seniorious(珂朵莉树)

    中文题面 珂朵莉树的板子……这篇文章很不错 据说还有奈芙莲树和瑟尼欧里斯树…… 等联赛考完去学一下(逃 //minamoto #include<bits/stdc++.h> #define ...

  6. Willem, Chtholly and Seniorious

    Willem, Chtholly and Seniorious https://codeforces.com/contest/897/problem/E time limit per test 2 s ...

  7. CF&&CC百套计划1 Codeforces Round #449 C. Willem, Chtholly and Seniorious (Old Driver Tree)

    http://codeforces.com/problemset/problem/896/C 题意: 对于一个随机序列,执行以下操作: 区间赋值 区间加 区间求第k小 区间求k次幂的和 对于随机序列, ...

  8. 【题解】Willem, Chtholly and Seniorious Codeforces 896C ODT

    Prelude ODT这个东西真是太好用了,以后写暴力骗分可以用,写在这里mark一下. 题目链接:ヽ(✿゚▽゚)ノ Solution 先把原题解贴在这里:(ノ*・ω・)ノ 简单地说,因为数据是全部随 ...

  9. 【模板】珂朵莉树(ODT)(Codeforces 896C Willem, Chtholly and Seniorious)

    题意简述 维护一个数列,支持区间加,区间赋值,区间求第k小,区间求幂和 数据随机 题解思路 ODT是一种基于std::set的暴力数据结构. 每个节点对应一段区间,该区间内的数都相等. 核心操作spl ...

随机推荐

  1. Linux - DNF包管理

    简介 link DNF(Dandified Yum)是新一代的RPM软件包管理器. DNF包管理器克服了YUM包管理器的一些瓶颈,提升了包括用户体验,内存占用,依赖分析,运行速度等多方面的内容. DN ...

  2. Python小白学习之路(二十五)—【装饰器的应用】

    通过一个任务来加深对装饰器的理解和应用 回顾:装饰器的框架 def timmer(func): def wrapper(): func() return wrapper 任务:给以下正在运行的程序加一 ...

  3. [Umbraco] Data Type之Render control

    继续探讨Data Type.如果你创建过Data Type,你就会知道创建一个新的Data Type都需要指定一个Render control,这有点类似开始C#时用到的继承. 那么如何创建我们自己的 ...

  4. 解决Navicat Premium终端操作mysql ONLY_FULL_GROUP_BY错误

    解决navicate终端操作mysql ONLY_FULL_GROUP_BY错误     问题描述: [Err] 1055 - Expression #1 of SELECT list is not ...

  5. 【原创】实现一个简单的邮件服务API

    经常在公司写一些内部小程序需要用到发邮件的功能,于是决定写一个邮件服务. 实现思路:以URL形式提供一个RESTful API 给客户端,客户端通过post请求把json格式的邮件信息发送到服务端,服 ...

  6. Delphi:程序自己删除自己,适用于任何windows版本(含源码)

    Delphi:程序自己删除自己,适用于任何windows版本(含源码) function Suicide: Boolean; var   sei: TSHELLEXECUTEINFO;   szMod ...

  7. ElasticSearch入门2: 基本用法

    基本用法:  一.索引创建 (启动集群和索引请看上一篇文章:http://www.cnblogs.com/liuxiaoming123/p/8081883.html) 1.打开浏览器,输入请求:htt ...

  8. Selenium自动化测试Python六:持续集成

    持续集成 欢迎阅读WebDriver持续集成讲义.本篇讲义将会重点介绍Selenium WebDriver API的在持续集成中的使用方法,以及使用Jenkins持续集成工具进行自动化测试的设计. 持 ...

  9. This Gradle plugin requires Studio 3.0 minimum

    从github上下载的项目遇到一个问题:Error:This Gradle plugin requires Studio 3.0 minimum 意思就是说studio版本不高,导入的项目的版本是3. ...

  10. [Java初探外篇]__关于时间复杂度与空间复杂度

    前言 我们在前面的排序算法的学习中了解到了,排序算法的分类,效率的比较所使用到的判断标准,就包括时间复杂度和空间复杂度,当时因为这两个定义还是比较难以理解的,所以决定单独开一篇文章,记录一下学习的过程 ...