题号 标题 已通过代码 题解/讨论 通过率 团队的状态
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. rm -rf /*时遇到的趣事

    今天在一个linux群里面闲逛的时候,突然看见一个愤青把自己的linux系统给 rm -rf /* 了 ,感觉很好玩就看了一下,突然我发现了有趣的事情! 我的朋友问我,这个为什么显示没有删除,我看了确 ...

  2. Restful API 中的错误处理

    简介 随着移动开发和前端开发的崛起,越来越多的 Web 后端应用都倾向于实现 Restful API. Restful API 是一个简单易用的前后端分离方案,它只需要对客户端请求进行处理,然后返回结 ...

  3. ansible-service

    #service#查询服务状态 ansible server01 -m service -a "name=httpd state=started" #停止服务 ansible se ...

  4. 1.Go语言copy函数、sort排序、双向链表、list操作和双向循环链表

    1.1.copy函数 通过copy函数可以把一个切片内容复制到另一个切片中 (1)把长切片拷贝到短切片中 package main import "fmt" func main() ...

  5. git的使用(一)

    git   —version  展示git的版本 tanya ~$ git --version git version 2.22.0 最小配置   git config —global user.na ...

  6. vue-cli3.0创建项目报npm install --loglevel error 踩坑的那把辛酸泪

    创建项目 vue create vue-pro 然后如下图 一开始以为是npm的问题,卸载了Mac的node ,安装nvm,然后再安装node (可参考: Mac中nvm的安装和使用   https: ...

  7. CSS:抗锯齿 font-smoothing

    本文引自:http://www.cnblogs.com/sunshq/p/4595673.html -webkit-font-smoothing 这个属性可以使页面上的字体抗锯齿,使用后字体看起来会更 ...

  8. APP启动优化

    1. 去除启动黑屏 1.1 在style.xml中定义两种主题: <style name="AppTheme" parent="Theme.AppCompat.Da ...

  9. p2p 打洞专场(转)

    就像1000个人眼中有1000个哈姆雷特一样,每个人眼中的区块链也是不一样的!作为技术人员眼中的区块链就是将各种技术的融合,包括密码学,p2p网络,分布式共识机制以及博弈论等.我们今天就来讨论一下区块 ...

  10. 测试自动化:java+selenium3 UI自动化(1) - 环境搭建

    1.前言 我大概是在2012年第一次正式接触到自动化测试,那个时候跟随我的团队一起,就当时项目的UI自动化尝试做出了探索. 在我离开那家公司的时候,我们的自动化测试体系仍然难言完美,但是也已经达到了非 ...