A:正着DFS一次处理出每个节点有多少个优先级比他低的(包括自己)作为值v[i] 求A B 再反着DFS求优先级比自己高的求C

  1. #include <bits/stdc++.h>
  2. #include <cstring>
  3. #include <iostream>
  4. #include <algorithm>
  5. #define EPS 1.0e-9
  6. #define PI acos(-1.0)
  7. #define INF 30000000
  8. #define MOD 1000000007
  9. #define mem(a,b) memset((a),b,sizeof(a))
  10. #define TS printf("!!!\n")
  11. #define pb push_back
  12. #define pai pair<int,int>
  13. //using ll = long long;
  14. //using ull= unsigned long long;
  15. //std::ios::sync_with_stdio(false);
  16. using namespace std;
  17. //priority_queue<int,vector<int>,greater<int>> que;
  18. typedef long long ll;
  19. typedef unsigned long long ull;
  20. const int maxn=;
  21. int value[maxn];
  22. int number[maxn];
  23. vector<int> pe[maxn];
  24. vector<int> pe2[maxn];
  25. //queue<int> que;
  26. void dfsgo(int x)
  27. {
  28. number[x]++;
  29. int len=pe2[x].size();
  30. for(int i=;i<len;i++)
  31. {
  32. if(!value[pe2[x][i]])
  33. {
  34. value[pe2[x][i]]=;
  35. dfsgo(pe2[x][i]);
  36. }
  37. }
  38. }
  39. void dfsback(int x)
  40. {
  41. number[x]++;
  42. int len=pe[x].size();
  43. for(int i=;i<len;i++)
  44. {
  45. if(!value[pe[x][i]])
  46. {
  47. value[pe[x][i]]=;
  48. dfsback(pe[x][i]);
  49. }
  50. }
  51. }
  52. int main()
  53. {
  54. int a,b,e,p;
  55. int anser1=;
  56. int anser2=;
  57. int anser3=;
  58. cin >> a >> b >> e >> p;
  59. mem(value,);
  60. mem(number,);
  61. int now,to;
  62. for(int i=;i<=p;i++)
  63. {
  64. scanf("%d %d",&now,&to);
  65. pe[now].pb(to);
  66. pe2[to].pb(now);
  67. }
  68. for(int i=;i<e;i++)
  69. {
  70. mem(value,);
  71. value[i]=;
  72. dfsgo(i);
  73. }
  74. //for(int i=0;i<e;i++)
  75. //cout<<number[i]<<" ";
  76. //cout<<endl;
  77. for(int i=;i<e;i++)
  78. {
  79. int curr=number[i];
  80. if(e-curr<a)
  81. anser1++;
  82. if(e-curr<b)
  83. anser2++;
  84. }
  85. mem(number,);
  86. for(int i=;i<e;i++)
  87. {
  88. mem(value,);
  89. value[i]=;
  90. dfsback(i);
  91. }
  92.  
  93. for(int i=;i<e;i++)
  94. if(number[i]>b)
  95. anser3++;
  96. cout<<anser1<<endl<<anser2<<endl<<anser3;
  97. }

C:哈夫曼树做法

D:签到题 直接暴力

E:递推DP

  1. #include <bits/stdc++.h>
  2. #include <cstring>
  3. #include <iostream>
  4. #include <algorithm>
  5. #define EPS 1.0e-9
  6. #define PI acos(-1.0)
  7. #define INF 30000000
  8. #define MOD 1000000007
  9. #define mem(a,b) memset((a),b,sizeof(a))
  10. #define TS printf("!!!\n")
  11. #define pb push_back
  12. #define pai pair<int,int>
  13. //using ll = long long;
  14. //using ull= unsigned long long;
  15. //std::ios::sync_with_stdio(false);
  16. using namespace std;
  17. //priority_queue<int,vector<int>,greater<int>> que;
  18. typedef long long ll;
  19. typedef unsigned long long ull;
  20. ll mod=;
  21. int a[];
  22. ll ans[][];
  23. ll anser=;
  24. int main()
  25. {
  26. int n;
  27. while(~scanf("%d",&n))
  28. {
  29. //mem(ans,0);
  30. anser=;
  31. int x;
  32. ll minn;
  33. ll maxn;
  34. ll now;
  35. for(int i=;i<=n;i++)
  36. scanf("%d",&a[i]);
  37. ans[][a[]]=;
  38. for(int i=;i<=n;i++)
  39. for(int j=;j<=n+;j++)
  40. {
  41. minn=min(a[i-],j);
  42. maxn=max(a[i-],j);
  43. now=a[i];
  44. if(now>minn)
  45. {
  46. ans[i][minn]=(ans[i][minn]+ans[i-][j])%mod;
  47. }
  48. if(now<maxn)
  49. {
  50. ans[i][maxn]=(ans[i][maxn]+ans[i-][j])%mod;
  51. }
  52. }
  53. for(int i=;i<=n+;i++)
  54. anser+=ans[n][i];
  55. cout<<anser%mod<<endl;
  56. }
  57. }

F!:网络流

G:SG函数

H:问区间[x,y]中有多少数的二进制表示是ABAB..AB型或者A型的,其中A是n个1,B是m个0,n,m>0  直接暴力

J:凸包+扫描线+二分

给出l个大点和s个小点,问有多少小点被三个大点组成的三角形覆盖

  1. #include <bits/stdc++.h>
  2. #define MN 10010
  3. #define pi acos(-1.0)
  4. using namespace std;
  5. typedef long long LL;
  6.  
  7. struct Point {
  8. LL x, y;
  9.  
  10. Point(LL x = , LL y = ) : x(x), y(y) {}
  11.  
  12. bool operator<(const Point &rhs) const { return x < rhs.x || (x == rhs.x && y < rhs.y); }
  13.  
  14. Point operator-(const Point &rhs) const { return Point(x - rhs.x, y - rhs.y); }
  15.  
  16. LL operator^(const Point &rhs) const { return x * rhs.y - y * rhs.x; }
  17. } a[MN], p[MN];
  18.  
  19. int n, tot;
  20.  
  21. void ConvexHull() {
  22. sort(a + , a + + n);
  23. tot = ;
  24. for (int i = ; i <= n; i++) {
  25. while (tot > && ((p[tot - ] - p[tot - ]) ^ (a[i] - p[tot - ])) <= )tot--;
  26. p[tot++] = a[i];
  27. }
  28. int k = tot;
  29. for (int i = n - ; i > ; i--) {
  30. while (tot > k && ((p[tot - ] - p[tot - ]) ^ (a[i] - p[tot - ])) <= )tot--;
  31. p[tot++] = a[i];
  32. }
  33. if (n > )tot--;
  34. }
  35.  
  36. bool Judge(Point A) {
  37. int l = , r = tot - , mid;
  38. while (l <= r) {
  39. mid = (l + r) / ;
  40. LL a1 = (p[mid] - p[]) ^ (A - p[]);
  41. LL a2 = (p[mid + ] - p[]) ^ (A - p[]);
  42. if (a1 >= && a2 <= ) {
  43. if (((p[mid + ] - p[mid]) ^ (A - p[mid])) >= )return true;
  44. return false;
  45. } else if (a1 < ) {
  46. r = mid - ;
  47. } else {
  48. l = mid + ;
  49. }
  50. }
  51. return false;
  52. }
  53.  
  54. int s, ans = ;
  55.  
  56. int main() {
  57. cin >> n;
  58. for (int i = ; i <= n; i++) cin >> a[i].x >> a[i].y;;
  59. ConvexHull();
  60. cin >> s;
  61. Point t;
  62. for (int i = ; i <= s; i++) {
  63. cin >> t.x >> t.y;
  64. if (Judge(t)) ans++;
  65. }
  66. printf("%d", ans);
  67. return ;
  68. }

Summer training round2 #5 (Training #21)的更多相关文章

  1. Summer training round2 #10(Training 30)

    A:签到题 B!:搜索+DP #include<bits/stdc++.h> #define mp make_pair #define pi pair<int,int> usi ...

  2. Summer training round2 #7 (Training #23)

    A:约瑟夫环 套公式 B:线性筛素数 C:投骰子 概率DP F:有权无向图的生成树(边最大值和最小值只差最小) 直接kruskal G:状压BFS或者双向BFS H:模拟题 I:几何题 J:高斯消元

  3. Summer training round2 #6 (Training #22)

    A:二分答案 如果中位数比目前的大就right=mid-1 else left=mid+1 C!:几何 G:优先队列贪心 #include <bits/stdc++.h> using na ...

  4. Summer training round2 #4 (Training #20)

    A!:UESTC1752 B!:找区间内L到R之间内的数的个数  权值分块加莫队 C!:给你一个哈斯图 去掉其中的几条边 要求输出字典序最大的拓扑排序:线段树模拟拓扑排序 D!:要求你找到最短路树并输 ...

  5. [WeChall] Training: Encodings I (Training, Encoding)

    Training: Encodings I (Training, Encoding) We intercepted this message from one challenger to anothe ...

  6. Summer training round2 #3

    A!:                    GTY系列题 B!:莫队加分块  GTY系列题 C!:线段树模拟拓扑排序(把普通的拓扑排序的栈操作改成线段树区间减一,查询区间最右侧的0的位置即可.注意一 ...

  7. Summer training round2 #1

    A:水 B:求两个三角形之间的位置关系:相交 相离 内含 ①用三个点是否在三角形内外判断    计算MA*MB.MB*MC.MC*MA的大小 若这三个值同号,那么在三角形的内部,异号在外部 #incl ...

  8. Summer training round2 #8(Training26)

    A:贪心DFS 先从最远的搜起 如果一个点的value>=2 就ans++ D:并查集 E:大模拟 F:快速幂 #include <bits/stdc++.h> using name ...

  9. Summer training round2 #9(Training28)

    A:签到题 C:模拟搜索题 #include <bits/stdc++.h> #include <cstring> #include <iostream> #inc ...

随机推荐

  1. Python深入学习之特殊方法与多范式

    Python深入学习之特殊方法与多范式 Python一切皆对象,但同时,Python还是一个多范式语言(multi-paradigm),你不仅可以使用面向对象的方式来编写程序,还可以用面向过程的方式来 ...

  2. Windows-T

    查看Windows系统版本号 同时按下Windows键和字母R键,然后输入winver就可以了 命令行运行计算器cmd-calc win10卸载XShell6报错1603 在运行里输入regedit打 ...

  3. LeetCode.1137-第N个泰波那契数(N-th Tribonacci Number)

    这是小川的第409次更新,第441篇原创 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第260题(顺位题号是1137).Tribonacci(泰波那契)序列Tn定义如下: 对于n&g ...

  4. C++笔记(1)——Anniversary

    世界太喧闹,不如敲代码. 直接上题目: Zhejiang University is about to celebrate her 122th anniversary in 2019. To prep ...

  5. Leetcode之动态规划(DP)专题-1025. 除数博弈(Divisor Game)

    Leetcode之动态规划(DP)专题-1025. 除数博弈(Divisor Game) 爱丽丝和鲍勃一起玩游戏,他们轮流行动.爱丽丝先手开局. 最初,黑板上有一个数字 N .在每个玩家的回合,玩家需 ...

  6. 【Linux开发】linux设备驱动归纳总结(三):6.poll和sellct

    linux设备驱动归纳总结(三):6.poll和sellct xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...

  7. Android Studio出现:Cause: unable to find valid certification path to requested target

    我的AS版本是3.4.1..出现这个问题是因为公司内网很奇葩,连上后必须访问一次网页.所以是AS连不上网络,访问不了https://bintray.com/bintray/jcenter导致的.

  8. NOIP2017普及组比赛总结

    期中考总结&NOIP2017总结 2017年11月11日,我第二次参加NOIP普及组复赛.上一年,我的得分是250分,只拿到了二等奖.我便把目标定为拿到一等奖,考到300分以上. 早上8点多, ...

  9. FFmpeg4.0笔记:封装ffmpeg的音频重采样功能类CSwr

    Github https://github.com/gongluck/FFmpeg4.0-study/tree/master/Cff CSwr.h /************************* ...

  10. java基础:强引用、弱引用、软引用和虚引用 (转)

    出处文章: Java基础篇 - 强引用.弱引用.软引用和虚引用 谈谈Java对象的强引用,软引用,弱引用,虚引用分别是什么 整体结构 java提供了4中引用类型,在垃圾回收的时候,都有自己的各自特点. ...