Summer training round2 #5 (Training #21)
A:正着DFS一次处理出每个节点有多少个优先级比他低的(包括自己)作为值v[i] 求A B 再反着DFS求优先级比自己高的求C
- #include <bits/stdc++.h>
- #include <cstring>
- #include <iostream>
- #include <algorithm>
- #define EPS 1.0e-9
- #define PI acos(-1.0)
- #define INF 30000000
- #define MOD 1000000007
- #define mem(a,b) memset((a),b,sizeof(a))
- #define TS printf("!!!\n")
- #define pb push_back
- #define pai pair<int,int>
- //using ll = long long;
- //using ull= unsigned long long;
- //std::ios::sync_with_stdio(false);
- using namespace std;
- //priority_queue<int,vector<int>,greater<int>> que;
- typedef long long ll;
- typedef unsigned long long ull;
- const int maxn=;
- int value[maxn];
- int number[maxn];
- vector<int> pe[maxn];
- vector<int> pe2[maxn];
- //queue<int> que;
- void dfsgo(int x)
- {
- number[x]++;
- int len=pe2[x].size();
- for(int i=;i<len;i++)
- {
- if(!value[pe2[x][i]])
- {
- value[pe2[x][i]]=;
- dfsgo(pe2[x][i]);
- }
- }
- }
- void dfsback(int x)
- {
- number[x]++;
- int len=pe[x].size();
- for(int i=;i<len;i++)
- {
- if(!value[pe[x][i]])
- {
- value[pe[x][i]]=;
- dfsback(pe[x][i]);
- }
- }
- }
- int main()
- {
- int a,b,e,p;
- int anser1=;
- int anser2=;
- int anser3=;
- cin >> a >> b >> e >> p;
- mem(value,);
- mem(number,);
- int now,to;
- for(int i=;i<=p;i++)
- {
- scanf("%d %d",&now,&to);
- pe[now].pb(to);
- pe2[to].pb(now);
- }
- for(int i=;i<e;i++)
- {
- mem(value,);
- value[i]=;
- dfsgo(i);
- }
- //for(int i=0;i<e;i++)
- //cout<<number[i]<<" ";
- //cout<<endl;
- for(int i=;i<e;i++)
- {
- int curr=number[i];
- if(e-curr<a)
- anser1++;
- if(e-curr<b)
- anser2++;
- }
- mem(number,);
- for(int i=;i<e;i++)
- {
- mem(value,);
- value[i]=;
- dfsback(i);
- }
- for(int i=;i<e;i++)
- if(number[i]>b)
- anser3++;
- cout<<anser1<<endl<<anser2<<endl<<anser3;
- }
C:哈夫曼树做法
D:签到题 直接暴力
E:递推DP
- #include <bits/stdc++.h>
- #include <cstring>
- #include <iostream>
- #include <algorithm>
- #define EPS 1.0e-9
- #define PI acos(-1.0)
- #define INF 30000000
- #define MOD 1000000007
- #define mem(a,b) memset((a),b,sizeof(a))
- #define TS printf("!!!\n")
- #define pb push_back
- #define pai pair<int,int>
- //using ll = long long;
- //using ull= unsigned long long;
- //std::ios::sync_with_stdio(false);
- using namespace std;
- //priority_queue<int,vector<int>,greater<int>> que;
- typedef long long ll;
- typedef unsigned long long ull;
- ll mod=;
- int a[];
- ll ans[][];
- ll anser=;
- int main()
- {
- int n;
- while(~scanf("%d",&n))
- {
- //mem(ans,0);
- anser=;
- int x;
- ll minn;
- ll maxn;
- ll now;
- for(int i=;i<=n;i++)
- scanf("%d",&a[i]);
- ans[][a[]]=;
- for(int i=;i<=n;i++)
- for(int j=;j<=n+;j++)
- {
- minn=min(a[i-],j);
- maxn=max(a[i-],j);
- now=a[i];
- if(now>minn)
- {
- ans[i][minn]=(ans[i][minn]+ans[i-][j])%mod;
- }
- if(now<maxn)
- {
- ans[i][maxn]=(ans[i][maxn]+ans[i-][j])%mod;
- }
- }
- for(int i=;i<=n+;i++)
- anser+=ans[n][i];
- cout<<anser%mod<<endl;
- }
- }
F!:网络流
G:SG函数
H:问区间[x,y]中有多少数的二进制表示是ABAB..AB型或者A型的,其中A是n个1,B是m个0,n,m>0 直接暴力
J:凸包+扫描线+二分
给出l个大点和s个小点,问有多少小点被三个大点组成的三角形覆盖
- #include <bits/stdc++.h>
- #define MN 10010
- #define pi acos(-1.0)
- using namespace std;
- typedef long long LL;
- struct Point {
- LL x, y;
- Point(LL x = , LL y = ) : x(x), y(y) {}
- bool operator<(const Point &rhs) const { return x < rhs.x || (x == rhs.x && y < rhs.y); }
- Point operator-(const Point &rhs) const { return Point(x - rhs.x, y - rhs.y); }
- LL operator^(const Point &rhs) const { return x * rhs.y - y * rhs.x; }
- } a[MN], p[MN];
- int n, tot;
- void ConvexHull() {
- sort(a + , a + + n);
- tot = ;
- for (int i = ; i <= n; i++) {
- while (tot > && ((p[tot - ] - p[tot - ]) ^ (a[i] - p[tot - ])) <= )tot--;
- p[tot++] = a[i];
- }
- int k = tot;
- for (int i = n - ; i > ; i--) {
- while (tot > k && ((p[tot - ] - p[tot - ]) ^ (a[i] - p[tot - ])) <= )tot--;
- p[tot++] = a[i];
- }
- if (n > )tot--;
- }
- bool Judge(Point A) {
- int l = , r = tot - , mid;
- while (l <= r) {
- mid = (l + r) / ;
- LL a1 = (p[mid] - p[]) ^ (A - p[]);
- LL a2 = (p[mid + ] - p[]) ^ (A - p[]);
- if (a1 >= && a2 <= ) {
- if (((p[mid + ] - p[mid]) ^ (A - p[mid])) >= )return true;
- return false;
- } else if (a1 < ) {
- r = mid - ;
- } else {
- l = mid + ;
- }
- }
- return false;
- }
- int s, ans = ;
- int main() {
- cin >> n;
- for (int i = ; i <= n; i++) cin >> a[i].x >> a[i].y;;
- ConvexHull();
- cin >> s;
- Point t;
- for (int i = ; i <= s; i++) {
- cin >> t.x >> t.y;
- if (Judge(t)) ans++;
- }
- printf("%d", ans);
- return ;
- }
Summer training round2 #5 (Training #21)的更多相关文章
- Summer training round2 #10(Training 30)
A:签到题 B!:搜索+DP #include<bits/stdc++.h> #define mp make_pair #define pi pair<int,int> usi ...
- Summer training round2 #7 (Training #23)
A:约瑟夫环 套公式 B:线性筛素数 C:投骰子 概率DP F:有权无向图的生成树(边最大值和最小值只差最小) 直接kruskal G:状压BFS或者双向BFS H:模拟题 I:几何题 J:高斯消元
- Summer training round2 #6 (Training #22)
A:二分答案 如果中位数比目前的大就right=mid-1 else left=mid+1 C!:几何 G:优先队列贪心 #include <bits/stdc++.h> using na ...
- Summer training round2 #4 (Training #20)
A!:UESTC1752 B!:找区间内L到R之间内的数的个数 权值分块加莫队 C!:给你一个哈斯图 去掉其中的几条边 要求输出字典序最大的拓扑排序:线段树模拟拓扑排序 D!:要求你找到最短路树并输 ...
- [WeChall] Training: Encodings I (Training, Encoding)
Training: Encodings I (Training, Encoding) We intercepted this message from one challenger to anothe ...
- Summer training round2 #3
A!: GTY系列题 B!:莫队加分块 GTY系列题 C!:线段树模拟拓扑排序(把普通的拓扑排序的栈操作改成线段树区间减一,查询区间最右侧的0的位置即可.注意一 ...
- Summer training round2 #1
A:水 B:求两个三角形之间的位置关系:相交 相离 内含 ①用三个点是否在三角形内外判断 计算MA*MB.MB*MC.MC*MA的大小 若这三个值同号,那么在三角形的内部,异号在外部 #incl ...
- Summer training round2 #8(Training26)
A:贪心DFS 先从最远的搜起 如果一个点的value>=2 就ans++ D:并查集 E:大模拟 F:快速幂 #include <bits/stdc++.h> using name ...
- Summer training round2 #9(Training28)
A:签到题 C:模拟搜索题 #include <bits/stdc++.h> #include <cstring> #include <iostream> #inc ...
随机推荐
- Python深入学习之特殊方法与多范式
Python深入学习之特殊方法与多范式 Python一切皆对象,但同时,Python还是一个多范式语言(multi-paradigm),你不仅可以使用面向对象的方式来编写程序,还可以用面向过程的方式来 ...
- Windows-T
查看Windows系统版本号 同时按下Windows键和字母R键,然后输入winver就可以了 命令行运行计算器cmd-calc win10卸载XShell6报错1603 在运行里输入regedit打 ...
- LeetCode.1137-第N个泰波那契数(N-th Tribonacci Number)
这是小川的第409次更新,第441篇原创 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第260题(顺位题号是1137).Tribonacci(泰波那契)序列Tn定义如下: 对于n&g ...
- C++笔记(1)——Anniversary
世界太喧闹,不如敲代码. 直接上题目: Zhejiang University is about to celebrate her 122th anniversary in 2019. To prep ...
- Leetcode之动态规划(DP)专题-1025. 除数博弈(Divisor Game)
Leetcode之动态规划(DP)专题-1025. 除数博弈(Divisor Game) 爱丽丝和鲍勃一起玩游戏,他们轮流行动.爱丽丝先手开局. 最初,黑板上有一个数字 N .在每个玩家的回合,玩家需 ...
- 【Linux开发】linux设备驱动归纳总结(三):6.poll和sellct
linux设备驱动归纳总结(三):6.poll和sellct xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...
- Android Studio出现:Cause: unable to find valid certification path to requested target
我的AS版本是3.4.1..出现这个问题是因为公司内网很奇葩,连上后必须访问一次网页.所以是AS连不上网络,访问不了https://bintray.com/bintray/jcenter导致的.
- NOIP2017普及组比赛总结
期中考总结&NOIP2017总结 2017年11月11日,我第二次参加NOIP普及组复赛.上一年,我的得分是250分,只拿到了二等奖.我便把目标定为拿到一等奖,考到300分以上. 早上8点多, ...
- FFmpeg4.0笔记:封装ffmpeg的音频重采样功能类CSwr
Github https://github.com/gongluck/FFmpeg4.0-study/tree/master/Cff CSwr.h /************************* ...
- java基础:强引用、弱引用、软引用和虚引用 (转)
出处文章: Java基础篇 - 强引用.弱引用.软引用和虚引用 谈谈Java对象的强引用,软引用,弱引用,虚引用分别是什么 整体结构 java提供了4中引用类型,在垃圾回收的时候,都有自己的各自特点. ...