题号 标题 已通过代码 题解/讨论 通过率 团队的状态
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. idea中写servlet时报错--关于405错误

    将super方法注释掉 原因:super是调用了此类继承父类doget和dopost方法的, 如果此类中没有这个方法,就会报错The specified HTTP method is not allo ...

  2. 在 Windows 上使用 Python 进行 web 开发

    本文由葡萄城技术团队于原创并首发 转载请注明出处:葡萄城官网,葡萄城为开发者提供专业的开发工具.解决方案和服务,赋能开发者. 上一篇我们介绍了在Windows 10下进行初学者入门开发Python的指 ...

  3. 检测人脸及眼睛【OpenCV-Python实现 源码+打包.exe文件】

    之前用opencv做的一个人脸及双眼检测,在此分享给大家 链接:https://pan.baidu.com/s/1BsKBH3wOF9TmdbRlPagEVQ 提取码:cqkv 效果如下:

  4. DesignPattern系列__05开闭原则

    介绍 开闭原则是编程设计中最基本.最重要的原则. 定义:一个软件实体如类.方法和模块等,应该对扩展(提供方)开放,对修改(使用方)关闭.用抽象构建框架,用实现扩展细节. 也就是说,在需求发生新的变化时 ...

  5. IO流与NIO流

    JAVA IO流最详解   (转自CSDN) IO流上:概述.字符流.缓冲区(java基础)   一.IO流概述 概述: IO流简单来说就是Input和Output流,IO流主要是用来处理设备之间的数 ...

  6. Java | Map排序,工具类改进

    package util; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; ...

  7. 33行代码爬取妹子图片(bs4+urllib)

    from bs4 import BeautifulSoupimport urllib2import urllibimport lxmlimport os def get_imgs(): image_c ...

  8. Activiti6系列(5)- 核心API

    前言 本来想把<疯狂工作流讲义-activiti6.0>这本书里面的实例拿过来,但是这本书我看完后,认为里面编写的activiti6的核心API代码片段不是很清晰,有不少需要雕琢的地方才好 ...

  9. JMS入门简介

    一.JMS是什么 1.JMS即Java消息服务(Java Message Service)应用程序接口,是一个Java平台中关于面向消息中间件(MOM)的API,用于在两个应用程序之间,或分布式系统中 ...

  10. asp.net core 一个中小型项目实战的起手式——项目搭建与仓储模式下的持久层创建(1)

    常规的中小型项目搭建方式一般是三层架构加上mvc与webapi作为一个主要框架,再加上一些第三方库,例如orm框架(EF.SqlSugar.Dapper等),API文档工具(Swagger)这些的应用 ...