摘要: Gym103049F 注意到任意碰撞只会发生在还存在的两个相邻的石块中。 我们对记录下每一个可能发生碰撞的时间。存入一个优先队列里,队首是最先发生的碰撞。 再使用一个set维护还存在的石头。同时用vis记录一下。 每次弹出队首,一个碰撞,若此碰撞的两石子都存在,那么本碰撞发生,将两个石头从set中删 阅读全文
posted @ 2021-04-17 20:33 yesuweiYYYY 阅读(90) 评论(0) 推荐(0) 编辑
摘要: string 容器 常见用法 string s1 = "Hello" string s2("Hello") string s3(s2) string s4 = s3 getline(cin,s)// 从cin中读取一行给s s.empty()// 空?true:false; s.size()//返回 阅读全文
posted @ 2021-04-17 13:30 yesuweiYYYY 阅读(44) 评论(0) 推荐(0) 编辑
摘要: SDU 第七周CSP模拟题 A 解:数一下每种颜色袜子的个数,再除以2加到答案里即可 #include <iostream> #include <cmath> using namespace std; const int N = 100010; void in(int &x){ scanf("%d" 阅读全文
posted @ 2021-04-17 12:42 yesuweiYYYY 阅读(96) 评论(0) 推荐(0) 编辑
摘要: int sgn(double x){ if (x>eps)return 1; if (x<-eps)return -1; return 0; } struct vec{ double x,y; vec(){x=y=0;} vec(double _x,double _y){x=_x,y=_y;} ve 阅读全文
posted @ 2021-04-09 22:57 yesuweiYYYY 阅读(41) 评论(0) 推荐(0) 编辑
摘要: 求数组中前k个元素的最大值 class FRISTQUEUE{ public: int k; deque<int>q; deque<int>id; void push(int x,int tid){ while(!q.empty()&&q.back()<x){ q.pop_back(); id.po 阅读全文
posted @ 2021-04-05 13:31 yesuweiYYYY 阅读(30) 评论(0) 推荐(0) 编辑
摘要: /* 辛普森积分公式:sum(l,r)=( f(l)+f(r)+4*f((l+r)/2) ) * (r-l) / 6 解: 对 f 函数在 (l,r) 的积分可以用 以上函数拟合 欲对 (l,r) 的一段函数积分并给出了精度要求 可以对此段区间,递归使用上述公式(以设置的精度作为递归终点)即可以得到 阅读全文
posted @ 2021-01-22 15:51 yesuweiYYYY 阅读(1105) 评论(0) 推荐(0) 编辑
摘要: /* * 辛普森积分公式:sum(l,r)=( f(l)+f(r)+4*f((l+r)/2) ) * (r-l) / 6 * 解: 对 f 函数在 (l,r) 的积分可以用 以上函数拟合 * * 欲对 (l,r) 的一段函数积分并给出了精度要求 * 可以对此段区间,递归使用上述公式(以设置的精度作为 阅读全文
posted @ 2021-01-14 21:15 yesuweiYYYY 阅读(284) 评论(0) 推荐(0) 编辑
摘要: #include<bits/stdc++.h> using namespace std; const long long mod=1e9+7; const long long mod2 = 1e8+7; const long long N =1e6+10; void in(long long &x) 阅读全文
posted @ 2021-01-14 20:55 yesuweiYYYY 阅读(44) 评论(0) 推荐(0) 编辑
摘要: /* * 求边双连通分量 * 整体思路就是在图上dfs 并记录时间戳 * 相较于有向图 只需要注意一条边的两个节点即可 */ #include <bits/stdc++.h> #define N 1000010 #define p(a) putchar(a) using namespace std; 阅读全文
posted @ 2020-12-10 17:15 yesuweiYYYY 阅读(86) 评论(0) 推荐(0) 编辑
摘要: /*网络流最大流模板 输入: 点数n,边数m,起点s,终点t m条边:起点,终点,最大流量 输出: 最大流*/ const int maxn=10010; const int inf=1e15; int n,m,s,t; struct edge{ int to,next,value; }e[maxn 阅读全文
posted @ 2020-11-17 09:26 yesuweiYYYY 阅读(66) 评论(0) 推荐(0) 编辑