题号 标题 已通过代码 题解/讨论 通过率 团队的状态
A String 点击查看 进入讨论 566/3539  通过
B Irreducible Polynomial 点击查看 规律 730/2290 未通过
C Governing sand 点击查看 进入讨论 388/2088  通过
D Number 点击查看 进入讨论 959/1469  通过
E Find the median 点击查看 离散化 88/985 OK
F Energy stones 点击查看 BIT 16/132 未通过
G Make Shan Happy 点击查看 进入讨论 3/29 未通过
H Pair 点击查看 数位DP 93/245 OK
I Chessboard 点击查看 进入讨论 17/83 未通过
J A+B problem 点击查看 进入讨论 1024/1844  通过
K Function 点击查看 进入讨论 8/49 未通过

E-Find the median

题意

n次操作,($n \le 400000$),每次给出$L_i, R_i$向集合中插入,让你把$[L_i, L_i+1, L_i+2, ... , R_i]$ 插入到集合中,同时输出集合的中位数。

集合一开始为空,($1 \le L_i, R[i] \le 1e9$)

思路

空间有限,所以不可以把两个端点间的一段单独拿出来当成一个点

动态开点也被卡了空间

具体思路还是离散化,我们可以中间的点和左端点看成一个点

把原来对闭区间的操作改为对左闭右开区间的操作

就是把原来的$[L_i, R_i]$ 更改为 $[L_i, R_i + 1)$

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize(4)
#include <algorithm>
#include <iterator>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <cassert>
// #include<bits/extc++.h>
// using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define fi first
#define se second
#define debug(x) cerr<<#x << " := " << x << endl;
#define bug cerr<<"-----------------------"<<endl;
#define FOR(a, b, c) for(int a = b; a <= c; ++ a) typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll; const int inf = 0x3f3f3f3f;
const ll inff = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9+; template<typename T>
inline T read(T&x){
x=;int f=;char ch=getchar();
while (ch<''||ch>'') f|=(ch=='-'),ch=getchar();
while (ch>=''&&ch<='') x=x*+ch-'',ch=getchar();
return x=f?-x:x;
} /**********showtime************/
const int big = 1e9;
const int maxn = ;
int X[maxn],Y[maxn];
int L[maxn], R[maxn];
int a1,b1,c1,m1;
int a2,b2,c2,m2;
struct node{
int cnt;
ll sum;
int lazy;
int len;
} tree[maxn * ];
//离散化
vector<int>vec;
int getid(int x) {
return lower_bound(vec.begin(), vec.end(), x) - vec.begin() + ;
}
// void pushdown(int le,int ri,int rt) {
tree[rt<<].cnt += tree[rt].lazy;
tree[rt<<|].cnt += tree[rt].lazy;
tree[rt<<].lazy += tree[rt].lazy;
tree[rt<<|].lazy += tree[rt].lazy;
int mid = (le + ri) >> ; tree[rt<<].sum += 1ll*tree[rt].lazy * (vec[mid] - vec[le-]);
tree[rt<<|].sum += 1ll*tree[rt].lazy *(vec[ri] - vec[mid]);
tree[rt].lazy = ;
} void update(int L, int R, int le, int ri, int rt) {
if(le >= L && ri <= R) {
tree[rt].lazy++;
tree[rt].cnt++;
//因为每个节点表示【le实际值,ri实际值)的长度。
tree[rt].sum += 1ll*(vec[ri] - vec[le - ]);
return;
}
int mid = (le + ri) >> ;
if(tree[rt].lazy) pushdown(le,ri,rt);
if(mid >= L) {
update(L, R, le, mid, rt<<);
}
if(mid < R) {
update(L, R, mid+, ri, rt<<|);
}
tree[rt].sum = tree[rt<<].sum + tree[rt<<|].sum;
} int query(ll tot, int le, int ri, int rt) {
if(le == ri) { int cnt = tree[rt].cnt, res;
int lbound = vec[le-];
if(tot % cnt == ) {
res = lbound + tot / cnt - ;
}
else
res = lbound + tot / cnt;
return res; } int mid = (le + ri) >> ;
if(tree[rt].lazy) pushdown(le,ri,rt); ll lsum = tree[rt<<].sum;
if(lsum >= tot) return query(tot,le, mid, rt<<);
else return query(tot - lsum, mid+, ri, rt<<|);
}
int main(){ int n;
scanf("%d", &n);
scanf("%d%d%d%d%d%d", &X[], &X[], &a1, &b1, &c1, &m1);
scanf("%d%d%d%d%d%d", &Y[], &Y[], &a2, &b2, &c2, &m2); L[] = min(X[], Y[]) + ;
R[] = max(X[], Y[]) + ;
L[] = min(X[], Y[]) + ;
R[] = max(X[], Y[]) + ;
//因为我后面操作的是左闭右开区间,所以这里右端点++。
R[] ++; R[] ++;
vec.pb(L[]);vec.pb(R[] );
vec.pb(L[]);vec.pb(R[]);
for(int i=; i<=n; i++) {
X[i] = (1ll*a1 * X[i-] + 1ll*b1 * X[i-] + c1 )% m1;
Y[i] = (1ll*a2 * Y[i-] + 1ll*b2 * Y[i-] + c2 )% m2;
L[i] = min(X[i], Y[i]) + ;
R[i] = max(X[i], Y[i]) + ;
R[i] ++;
vec.pb(L[i]); vec.pb(R[i]);
}
sort(vec.begin(), vec.end());
vec.erase(unique(vec.begin(), vec.end()), vec.end());
for(int i=; i<=n; i++) {
L[i] = getid(L[i]);
R[i] = getid(R[i]);
} int tot = vec.size(); ll all = ; for(int i=; i<=n; i++) { update(L[i], R[i] - , , tot, ); all += 1ll*(vec[R[i]-] - vec[L[i] - ]); printf("%d\n", query((all + )/, , tot, ));
}
return ;
}

H Pair

题意

给定A,B,C($A \le 1e9, B \le 1e9, C \le 1e9$),求满足

$$ (x \& y) > C $$

$$ (x \oplus y)  < C$$

的<x, y>对数。其中

$ 1 \le x \le A, 1 \le y \le B$

思路

数位DP,自己code了好久

/*
* @Author: chenkexing
* @Date: 2019-08-09 23:58:00
* @Last Modified by: chenkexing
* @Last Modified time: 2019-08-10 22:19:16
* @Link https://ac.nowcoder.com/acm/contest/887/H
*/
// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize(4)
#include <algorithm>
#include <iterator>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <cassert>
// #include<bits/extc++.h>
// using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define fi first
#define se second
#define debug(x) cerr<<#x << " := " << x << endl;
#define bug cerr<<"-----------------------"<<endl;
#define FOR(a, b, c) for(int a = b; a <= c; ++ a) typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll; const int inf = 0x3f3f3f3f;
const ll inff = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9+; template<typename T>
inline T read(T&x){
x=;int f=;char ch=getchar();
while (ch<''||ch>'') f|=(ch=='-'),ch=getchar();
while (ch>=''&&ch<='') x=x*+ch-'',ch=getchar();
return x=f?-x:x;
} /**********showtime************/
ll dp[][][][][][][];
//dp[len][limit1][limit2][ok1][ok2]
//由于两个数要大于0,所以多加上ok1,ok2.
//f1 &的, f2 ^的 // == 2 表示不行了
int shuA[],shuB[],shuC[];
ll dfs(int len, int limit1, int limit2, int ok1, int ok2, int f1, int f2){
if(f1 == && f2 == ) return ;
if(dp[len][limit1][limit2][ok1][ok2][f1][f2] != -)
return dp[len][limit1][limit2][ok1][ok2][f1][f2];
if(len == ) {
return ok1 && ok2 && (f1 == || f2 == );
} int up1 = , up2 = ;
if(limit1) up1 = shuA[len];
if(limit2) up2 = shuB[len];
ll res = ;
// cout<<len<<" " << up1<<" , " << up2<<endl;
for(int i=; i<=up1; i++) {
for(int j=; j<=up2; j++) { // if(len == 2)cout<<len << " " << i << " , " << j << " = " << f1 <<" , , " <<f2 << endl; if(f1 == || f2 == )
res += dfs(len-, limit1 && i == up1, limit2 && j == up2, ok1 || i, ok2 || j, f1, f2);
else {
int F1 = f1, F2 = f2;
if((i & j) < shuC[len]) F1 = ;
else if((i & j) > shuC[len]) F1 = max(F1, ); if((i ^ j) > shuC[len]) F2 = ;
else if((i ^ j) < shuC[len]) F2 = max(F2, );
res += dfs(len-, limit1 && i == up1, limit2 && j == up2, ok1 || i, ok2 || j, F1, F2);
}
} }
dp[len][limit1][limit2][ok1][ok2][f1][f2] = res;
return res;
} int main(){
int T; scanf("%d", &T);
while(T--) {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
memset(dp, -, sizeof(dp));
int len = ;
for(int i=; i<=len; i++) shuA[i] = a % , a = a >> ;
for(int i=; i<=len; i++) shuB[i] = b % , b = b >> ;
for(int i=; i<=len; i++) shuC[i] = c % , c = c >> ;
printf("%lld\n", dfs(len, , , , , , ));
}
return ;
}

2019nc#7的更多相关文章

  1. 2019nc#2

    A Eddy Walker 题意 你有n个点(0-n-1),按顺序形成一个环,初始时你在0的位子,你随机顺时针走一步或者逆时针走一步, 一旦你走到一个点后,环上所有点都被经过至少一次后,你就必须停下来 ...

  2. 2019nc#10

    题号 标题 已通过代码 题解/讨论 通过率 团队的状态 A Blackjack 点击查看 背包DP 32/109 补好了 B Coffee Chicken 点击查看 进入讨论 738/2992  通过 ...

  3. 2019nc#9

    题号 标题 已通过代码 题解/讨论 通过率 团队的状态 A The power of Fibonacci 点击查看 进入讨论 69/227 未通过 B Quadratic equation 点击查看 ...

  4. 2019NC#8

    题号 标题 已通过代码 题解/讨论 通过率 团队的状态 A All-one Matrices 点击查看 单调栈+前缀和 326/2017  通过 B Beauty Values 点击查看 进入讨论 8 ...

  5. 2019nc#6

    https://ac.nowcoder.com/acm/contest/886#question 题号 标题 已通过代码 题解/讨论 通过率 团队的状态 A Garbage Classificatio ...

  6. 2019nc#5

    题号 标题 已通过代码 题解/讨论 通过率 团队的状态 A digits 2 点击查看 1017/2384  通过 B generator 1 点击查看 567/3692  通过 C generato ...

  7. 2019nc#4

    题号 标题 已通过代码 题解 通过率 团队的状态 A meeting 点击查看 树直径 604/2055   B xor 点击查看 线段树维护线性基交 81/861 未通过 C sequence 点击 ...

  8. 2019nc#3

    题号 标题 已通过代码 题解/讨论 通过率 团队的状态 A Graph Games 点击查看 进入讨论 18/292 未通过 B Crazy Binary String 点击查看 1107/3615 ...

  9. 2019NC#1

    LINK B Integration 题意: 给定$a_1,a_2,...,a_n$, 计算 $$\frac{1}{π}\int_{0}^{\infty}\frac{1}{\prod\limits_{ ...

随机推荐

  1. hdoj 4762 Cut the Cake

    题意很简单就不说了. 解题的关键就是这个公式 answer=n/(m^(n-1)); 要用到大数的乘法.然后java水过. import java.util.*; import java.math.* ...

  2. DevOps实施历程-v1.0

    ​    有AF项目的成功案例(DevOps实施历程-半自动化),公司新项目全部依此为模板,实现了从代码到安装的自动化流水线,为此我输出了Jenkins自动化指南.AF项目指南等文档,方便大家查阅和参 ...

  3. Letters Shop

    B. Letters Shop time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  4. 0x33 同余

    目录 定义 同余类与剩余系 费马小定理 欧拉定理 证明: 欧拉定理的推论 证明: 应用: 定义 若整数 $a$ 和整数 $b$ 除以正整数 $m$ 的余数相等,则称 $a,b$ 模 $m$ 同余,记为 ...

  5. cogs 1254. 最难的任务 Dijkstra + 重边处理

    1254. 最难的任务 ★   输入文件:hardest.in   输出文件:hardest.out   简单对比时间限制:1 s   内存限制:128 MB [题目描述] 这个真的很难.算出 123 ...

  6. c# 三步递交模式调用同一个存储过程

    主要用于批量的sql操作:第一步创建中间表,第二步多次写数据到中间表,第三步 提交执行 创建三步递交的存储过程: CREATE PROC usp_testsbdj@bz int=0,@name VAR ...

  7. Java相关|Code Review Checklist(Server)

    安全 所有入参均经过校验,包括验证参数数据类型.范围.长度,尽可能采用白名单形式验证所有的输入.对于非法请求,记录WARN log.参考Input Validation Cheat Sheet:前后端 ...

  8. AUTOCAD二次开发-----删除一个图层里面的所有对象

    https://blog.csdn.net/aasswwe/article/details/40899759 private void Test() { // 获取当前文档和数据库 Document ...

  9. 剑指offer总结一:字符、数字重复问题

    问题1:字符串中第一个不重复的字符 题目描述 请实现一个函数用来找出字符流中第一个只出现一次的字符.例如,当从字符流中只读出前两个字符"go"时,第一个只出现一次的字符是" ...

  10. Appium+Python+Genymotion ------环境配置

    前言 之前总是在找方向,也研究了很多的工具,终于找到了适合自己的一套,打算把学习的过程做一个记录,给自己加深印象,也希望能给其他人一些帮助. 一.工具准备 1.Appium  //  http://a ...