题号 标题 已通过代码 题解/讨论 通过率 团队的状态
A The power of Fibonacci 点击查看 进入讨论 69/227 未通过
B Quadratic equation 点击查看 高次剩余 391/888 未通过
C Inversions of all permutations 点击查看 进入讨论 28/61 未通过
D Knapsack Cryptosystem 点击查看 进入讨论 606/2251  通过
E All men are brothers 点击查看 进入讨论 425/1117  通过
F Birthday Reminders 点击查看 进入讨论 5/11 未通过
G Checkers 点击查看 进入讨论 0/15 未通过
H Cutting Bamboos 点击查看 二分,主席树 187/834  通过
I KM and M 点击查看 进入讨论 19/296 未通过
J Symmetrical Painting 点击查看 进入讨论 227/930  通过

H Cutting Bamboos

这道题用主席树过的,记录下区间权值。

  1. // #pragma GCC optimize(2)
  2. // #pragma GCC optimize(3)
  3. // #pragma GCC optimize(4)
  4. #include <algorithm>
  5. #include <iterator>
  6. #include <iostream>
  7. #include <cstring>
  8. #include <cstdlib>
  9. #include <iomanip>
  10. #include <bitset>
  11. #include <cctype>
  12. #include <cstdio>
  13. #include <string>
  14. #include <vector>
  15. #include <stack>
  16. #include <cmath>
  17. #include <queue>
  18. #include <list>
  19. #include <map>
  20. #include <set>
  21. #include <cassert>
  22. #include <unordered_map>
  23. // #include<bits/extc++.h>
  24. // using namespace __gnu_pbds;
  25. using namespace std;
  26. #define pb push_back
  27. #define fi first
  28. #define se second
  29. #define debug(x) cerr<<#x << " := " << x << endl;
  30. #define bug cerr<<"-----------------------"<<endl;
  31. #define FOR(a, b, c) for(int a = b; a <= c; ++ a)
  32.  
  33. typedef long long ll;
  34. typedef unsigned long long ull;
  35. typedef long double ld;
  36. typedef pair<int, int> pii;
  37. typedef pair<ll, ll> pll;
  38.  
  39. const int inf = 0x3f3f3f3f;
  40. const ll inff = 0x3f3f3f3f3f3f3f3f;
  41. const int mod = 1e9+;
  42.  
  43. template<typename T>
  44. inline T read(T&x){
  45. x=;int f=;char ch=getchar();
  46. while (ch<''||ch>'') f|=(ch=='-'),ch=getchar();
  47. while (ch>=''&&ch<='') x=x*+ch-'',ch=getchar();
  48. return x=f?-x:x;
  49. }
  50. /**********showtime************/
  51.  
  52. const int N = 2e5 + , M = 4e6 + ;//M为节点个数,为Q*log(N)
  53. int root[N], lson[M], rson[M], value[M], tot = ;
  54. ll sum[M];
  55. const double eps = 1e-;
  56. //建树
  57. void build(int &x, int l, int r) {
  58. x = ++tot;
  59. value[x] = ;
  60. sum[x] = ;
  61. if(l == r) {
  62. return ;
  63. }
  64. int m = (l+r) >> ;
  65. build(lson[x], l, m);
  66. build(rson[x], m+, r);
  67. value[x] = value[lson[x]] + value[rson[x]];
  68. }
  69. // 将某个历史版本p位置的值加v
  70. void update(int old, int &x, int p, int v, int l, int r) {
  71. x = ++tot;
  72. lson[x] = lson[old], rson[x] = rson[old], value[x] = value[old] + v, sum[x] = sum[old] + p;
  73. if(l == r) return ;
  74. int m = (l+r) >> ;
  75. if(p <= m) update(lson[x], lson[x], p, v, l, m);
  76. else update(rson[x], rson[x], p, v, m+, r);
  77. }
  78. //访问某个历史版本L到R的区间和
  79. int query(int L, int R, int x, int l, int r) {
  80. if(L <= l && r <= R) return value[x];
  81. int m = (l+r) >> , ans = ;
  82. if(L <= m) ans += query(L, R, lson[x], l, m);
  83. if(R > m) ans += query(L, R, rson[x], m+, r);
  84. return ans;
  85. }
  86. ll query2(int L, int R, int x, int l, int r) {
  87. if(L <= l && r <= R) return sum[x];
  88. int m = (l+r) >> ;
  89. ll ans = ;
  90. if(L <= m) ans += query2(L, R, lson[x], l, m);
  91. if(R > m) ans += query2(L, R, rson[x], m+, r);
  92. return ans;
  93. }
  94. const int maxn = 2e5+;
  95. ll pre[maxn], a[maxn];
  96. double cal(double val, int L, int R) {
  97. int hi = floor(val);
  98. int cnt = query(, hi, root[R], , ) - query(, hi, root[L-], , );
  99. double ss = (R - L + - cnt) * val;
  100. ss += 1.0*query2(, hi,root[R], , ) - query2(, hi, root[L-], , );
  101. return ss;
  102. }
  103. int main(){
  104. int n,m;
  105. scanf("%d%d", &n, &m);
  106. build(root[], , );
  107. for(int i=; i<=n; i++) {
  108. scanf("%lld", &a[i]), pre[i] = pre[i-] + a[i];
  109. update(root[i-], root[i], a[i], , , );
  110. }
  111. while(m--) {
  112. int L, R, x, y;
  113. scanf("%d%d%d%d", &L, &R, &x, &y);
  114. ll ss = pre[R] - pre[L-];
  115. double nd = ss*1.0 / y *(y - x);
  116. double le = , ri = , res = ;
  117. //debug(nd);
  118. while(le + eps < ri) {
  119. double mid = (le + ri) / ;
  120. if(cal(mid, L, R) <= nd) le = mid, res = mid;
  121. else ri = mid;
  122. }
  123. printf("%.10f\n", res);
  124. }
  125. return ;
  126. }

J Symmetrical Painting

题意:

有n个矩形,宽度都为1,排列在坐标轴上,问消去一些矩形的一部分,使得原来的图形上下对称。这个对称图形最大可能面积。

思路:

有点类似扫描线的做法。

  1. /*
  2. * @Author: chenkexing
  3. * @Date: 2019-08-16 15:34:14
  4. * @Last Modified by: chenkexing
  5. * @Last Modified time: 2019-08-16 15:41:12
  6. */
  7.  
  8. // #pragma GCC optimize(2)
  9. // #pragma GCC optimize(3)
  10. // #pragma GCC optimize(4)
  11. #include <algorithm>
  12. #include <iterator>
  13. #include <iostream>
  14. #include <cstring>
  15. #include <cstdlib>
  16. #include <iomanip>
  17. #include <bitset>
  18. #include <cctype>
  19. #include <cstdio>
  20. #include <string>
  21. #include <vector>
  22. #include <stack>
  23. #include <cmath>
  24. #include <queue>
  25. #include <list>
  26. #include <map>
  27. #include <set>
  28. #include <cassert>
  29. // #include<bits/extc++.h>
  30. // using namespace __gnu_pbds;
  31. using namespace std;
  32. #define pb push_back
  33. #define fi first
  34. #define se second
  35. #define debug(x) cerr<<#x << " := " << x << endl;
  36. #define bug cerr<<"-----------------------"<<endl;
  37. #define FOR(a, b, c) for(int a = b; a <= c; ++ a)
  38.  
  39. typedef long long ll;
  40. typedef long double ld;
  41. typedef pair<int, int> pii;
  42. typedef pair<ll, ll> pll;
  43.  
  44. const int inf = 0x3f3f3f3f;
  45. const ll inff = 0x3f3f3f3f3f3f3f3f;
  46. const int mod = ;
  47.  
  48. template<typename T>
  49. inline T read(T&x){
  50. x=;int f=;char ch=getchar();
  51. while (ch<''||ch>'') f|=(ch=='-'),ch=getchar();
  52. while (ch>=''&&ch<='') x=x*+ch-'',ch=getchar();
  53. return x=f?-x:x;
  54. }
  55.  
  56. /**********showtime************/
  57. const int maxn = ;
  58. pii a[maxn * ];
  59.  
  60. int main(){
  61. int n;
  62. scanf("%d", &n);
  63. int tot = ;
  64. for(int i=; i<=n; i++) {
  65. int le,ri;
  66. scanf("%d%d", &le, &ri);
  67. // 在底,中点,高上有可能取到极值。
  68. a[++tot] = pii(*le, );
  69. a[++tot] = pii(le + ri, -);
  70. a[++tot] = pii(*ri, );
  71. }
  72. sort(a+, a++tot);
  73. ll ans = , sum = ;
  74. ll cnt = a[].se;
  75. for(int i=; i<=tot; i++) {
  76. sum += cnt * (a[i].fi - a[i-].fi);
  77. ans = max(ans, sum);
  78. cnt += a[i].se;
  79. }
  80. printf("%lld\n", ans);
  81. return ;
  82. }

2019nc#9的更多相关文章

  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#8

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

  4. 2019nc#7

    题号 标题 已通过代码 题解/讨论 通过率 团队的状态 A String 点击查看 进入讨论 566/3539  通过 B Irreducible Polynomial 点击查看 规律 730/229 ...

  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. javaweb入门----servlet简介

    servlet 上文已经了解了web服务器和http协议是怎么回事儿,并且也了解了浏览器与服务器之间的联系,现在要介绍一下服务器是如何处理来自客户端的请求的,这就是servlet. servlet:J ...

  2. 安装MySQL5.7 安装环境:CentOS7 64位 MINI版,

    安装环境:CentOS7 64位 MINI版,安装MySQL5.7 1.配置YUM源 在MySQL官网中下载YUM源rpm安装包:http://dev.mysql.com/downloads/repo ...

  3. 一文了解:Redis基础类型

    Redis基础类型 Redis特点 开源的,BSD许可高级的key-value存储系统 可以用来存储字符串,哈希结构,链表,集合 安装 windows:https://github.com/micro ...

  4. codeforces1088D_Ehab and another another xor problem交互题

    传送门 一道考验思维的交互题 大致思路就是从最高的二进制位向下询问 代入例子比如: 5 6 6 5 7 4 6 4 讨论一下 交互题的重点学会推理和归纳 #include <bits/stdc+ ...

  5. Re-Architecting the Video Gatekeeper(一)

    原文 https://medium.com/netflix-techblog/re-architecting-the-video-gatekeeper-f7b0ac2f6b00 本文介绍了了内容配置工 ...

  6. 分享我的GD32F450的IAP过程

    最近一个项目使用GD32F450VI+ESP8266需要做远程升级,基本参考正点原子IAP的那一章节,但是在GD32F450上却遇到了问题,无法跳转,然后使用正点原子的开发板stm32f429,以及s ...

  7. centos部署oracle rac单实例11.2.0.3数据库(使用asm磁盘)

    部署oracle rac单实例数据库,需要安装grid和datavase两部分,所以首先创建两个用户oracle和grid,因为不能使用root用户进行安装,在安装之前首先需要修改一些系统参数和安装一 ...

  8. Opengl_入门学习分享和记录_03_渲染管线(二)再谈顶点着色器以及顶点属性以及属性链接

    ---恢复内容开始--- 写在前面的废话:岂可修!感觉最近好忙啊,本来今天还有同学约我出去玩的.(小声bb) 正文开始:之前已经编译好的着色器中还有一些问题,比如 layout(location=0) ...

  9. echarts legend 限制规定显示个数,显示省略号,修改默认样式

    类似百度统计,有的时候legend的个数比较多,但是前端需要控制初始化显示的个数,以及最多显示的条数,先看效果图: 先给代码: <!DOCTYPE html> <html lang= ...

  10. trec 2019 fair ranking track

    trec 2019 fair ranking track     最近实验室要求参加trec 2019新出的track:fair ranking track.这里整理一下该任务的思想和要求.这次tra ...