题集
ZHXU1998
这个作者很懒,什么都没留下…
展开
-
Codeforces Round #598 (Div. 3) A~F题解
https://codeforces.com/contest/1256/pA. Payment Without Change题意 给了 a 个 n价值硬币 b个 1价值硬币 能不能拼出 S 问直接算下就行#include <bits/stdc++.h>using namespace std;const int maxn = 1e5 + 5;#define int long...原创 2019-11-05 23:36:19 · 254 阅读 · 0 评论 -
2019牛客暑期多校(第五场) 写题记录
A digits 2A题 找到 数字连续出现 同时是它倍数的 n 《100 输出长度也小于100*100//水#include <bits/stdc++.h>using namespace std;int main(){ int n, m; cin >> n; for(int i = 1; i <= n; i++) { cin >> ...原创 2019-08-05 17:07:13 · 119 阅读 · 0 评论 -
2019牛客暑期多校(第二场) 写题记录
A Eddy Walker你有n个点(0~n-1),按顺序形成一个环,初始时你在0的位子,你随机顺时针走一步或者逆时针走一步问你全部路过完时停在哪里的概率 除了 0 点 其他是等可能的 特判 一个点 就好#include <bits/stdc++.h>using namespace std;#define fastio ios::sync_with_stdio(false...原创 2019-07-26 21:25:51 · 154 阅读 · 0 评论 -
《算法竞赛进阶指南》 0x25 ~ 0x28 代码 + 杂谈
0x25推箱子。。。。。。。 是真的写废了。。。。矩阵距离这个就是常见点 一开始就把多元点 放入队列的写法#include <bits/stdc++.h>using namespace std;const int maxn = 1005;const int dx[] = {1, 0, -1, 0};const int dy[] = {0, 1, 0, -1};type...原创 2019-08-04 19:09:34 · 725 阅读 · 0 评论 -
《算法竞赛进阶指南》 0x68 ~ 0x67 代码 + 杂谈
二分图最大匹配之前 一直没有学匈牙利 只写DINIC 匈牙利也挺简单的 关键是好写多了orz关押罪犯https://blog.csdn.net/qq_40831340/article/details/88821278棋盘覆盖我依稀的记得 第一次见到是DP来着#include <bits/stdc++.h>using namespace std;const int max...原创 2019-08-04 17:26:59 · 424 阅读 · 0 评论 -
2019牛客暑期多校(第一场) 写题记录
A. Equivalent Prefixes很水的单调队列首先说是处理最低位置一样 那么肯定队首存的下标一样其次 1 ~ p 位置区间内每部分最小对应下标一样 那样的话 队列每次进入一个元素就可以想到如果每部分最小下标对应一样 那样队列队尾弹出数量应该是一致的 只需要保证 队列大小一致就完成了第一个可以去掉 因为弹出一致了#include<iostream>#includ...原创 2019-07-22 13:09:49 · 345 阅读 · 0 评论 -
《算法竞赛进阶指南》 0x21 ~ 0x24 代码 + 杂谈
树与图的遍历可达性统计这个原创 2019-07-22 08:26:47 · 397 阅读 · 0 评论 -
[线性基] 2019 航电多校第一场 B HDU 6579 Operation
#include <bits/stdc++.h>using namespace std;const int maxn = 5*1e5 + 5;int p[maxn][32], pos[maxn][32];/*线性基//////////*bool insert(LL val){ for(int i = 63; i >= 0; i --){ if...原创 2019-07-24 20:40:35 · 215 阅读 · 0 评论 -
2019 杭电多校第一场 E HDU 6582 Path (最短路图上的最小割)
E HDU 6582 Path使当前最短路 权值变了就行 同时坎的权值尽可能少我们考虑求出最短路图 然后跑最小割可以确定 d[v] == DJ.val[i] + d[u] 就是 最短路图上的边 加入网络流图中#include <iostream>#include <cstring>#include <queue>using namespace s...原创 2019-07-24 19:30:32 · 429 阅读 · 0 评论 -
2019牛客暑期多校(第四场) 写题记录
A meeting给了些关键点 在一棵树上 选取一个点让他们相聚 时间最短其实就是求树直径 不过这次dfs完 我们找最远点的时候只看标记点 第二次dfs完也一样#include <bits/stdc++.h>using namespace std;const int maxn = 1e5 + 5;int n, m, cnt;int head[maxn], d[maxn...原创 2019-07-28 11:39:02 · 119 阅读 · 0 评论 -
《算法竞赛进阶指南》 0x6A 代码 + 杂谈
舞动的晚会我自己写的 建图可能写错了 导致后面输出的像是可行边 我也很迷 感觉没有检错图匹配边(i,j) j到i连边非匹配边 (i,j) i到j连边匹配的左点i (i,S)不匹配的左点i (S,i)匹配的右点j (T,j)不匹配的右点j (j,T)然后用Tarjan求强连通分量(i,j)是可行边的条件:(i,j)是匹配边 或者 i,j在同一个scc里那么总边数减去可行边数...原创 2019-08-07 09:02:57 · 317 阅读 · 0 评论 -
2019牛客暑期多校(第七场) 写题记录
J A+B problem签到 翻转之后相加 再翻转#include<bits/stdc++.h>using namespace std;typedef long long ll;int main() { int t; cin >> t; while(t--) { string a, b; cin >...原创 2019-08-10 17:13:57 · 208 阅读 · 0 评论 -
2019牛客国庆集训派对day2 A B C F G K
https://ac.nowcoder.com/acm/contest/1107#questionA Easy h-indexA 题 读懂第一句话 我举得A B C 应该都一样简单的 翻译真难H _ index 指的是 论文引用次数 大于等于 h 的总数量 h的最大可能值所以 我们 A题 直接到这for 一边 找到论文总数量大于i的第一次时刻就好#include <bits/std...原创 2019-10-02 22:10:34 · 244 阅读 · 0 评论 -
2019牛客国庆集训派对day1 部分代码 A B E F I
A 全 1 子矩阵暴力跑 注意 它全0也是不可以的 我醉了 wa了一发#include <bits/stdc++.h>using namespace std;typedef long long ll;const int N = 1e2 + 10;int n, m;char mp[N][N];int main() { while(~scanf("%d %d"...原创 2019-10-01 16:54:11 · 365 阅读 · 0 评论 -
秦皇岛 2019 CCPC区域赛 部分代码
Decimal Time Limit: 2000/1000 MS (Java/Others) Memory Limit:131072/131072 K (Java/Others) Total Submission(s): 2010 AcceptedSubmission(s): 894Problem Description 给定一个正整数 n,要求判断 1n在十进制下是不是一个...原创 2019-09-28 21:45:55 · 345 阅读 · 0 评论 -
Educational Codeforces Round 72 Editorial A~D题解
好菜啊这次打的 都是思维题 不难的 自己打的好菜 菜的无话可说https://codeforces.com/contest/1217A.Creating a Character就是让 exp 分给 str 和 in 保证str 严格大于in这样的话 我们考虑把他们分屏的基础上算最多可以分几次用 (exp + str和in 的差 + 1 )/ 2 算出分配状态但是 这坑了 然后str 非...原创 2019-09-28 09:43:21 · 192 阅读 · 0 评论 -
Educational Codeforces Round 73 (Rated for Div. 2) C D题
C - Perfect Teamhttps://codeforces.com/contest/1221/problem/C推公式 好像有人二分过了首先 我们把 n m k 人分好 n m先分一样多余的扔k里面 int t = max(n, m) - min(n, m); k += t; if(n > m) n -= t; else m -= t;这样 第一...原创 2019-09-21 11:35:41 · 105 阅读 · 0 评论 -
牛客小白月赛17 E D F
F 题 方程不好直接解 二分求答案 (有单调性)D 题 数据太少 而且是静态的 直接先暴力所有的 输入完一个一个对就好E 题链接:https://ac.nowcoder.com/acm/contest/1085/E来源:牛客网题目描述小sun最近为了应付考试,正在复习图论,他现在学到了图的遍历,觉得太简单了,于是他想到了一个更加复杂的问题:无向图有n个点,从点1开始遍历,但是规定:按...原创 2019-09-21 08:44:42 · 233 阅读 · 0 评论 -
CF585-div2 A ~ E 题解
CF585-div2A. Yellow CardsA题没有啥好说的 模拟就完事了 我好菜啊 这题10分钟不出最少必然是尽可能分到上界 最多当然是优先罚 容量少的啦#include <bits/stdc++.h>using namespace std;typedef long long ll;const int maxn = 1e5 + 5;const double ep...原创 2019-09-19 01:00:52 · 239 阅读 · 0 评论 -
2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛
HDU 6702 ^ & ^这题Bit operation is a common computing method in computer science ,Now we have two positive integers A and B ,Please find a positive integer C that minimize the value of the form...原创 2019-08-24 20:47:32 · 388 阅读 · 0 评论 -
2019 ICPC 南昌现场赛 重现(部分)
A. Attackpoj 3123板子题 斯坦纳树板子 如下const int maxm=2009;const int maxn=39;const int inf=0x3f3f3f3f; struct Edge{ int v,w,next;}edge[maxm]; int head[maxn],top; void init(){ memset(head,...原创 2019-07-24 19:25:43 · 1769 阅读 · 5 评论 -
《算法竞赛进阶指南》 0x13 + 0x17 代码 + 杂谈
链表数组模拟大法好啊 orz 前向星 + 数组下标搞得各种线段树什么得邻值查找STL嚎啊#include <iostream>#include <set>using namespace std;typedef pair<int, int> P;const int maxn = 1e5 + 5;#define int long longst...原创 2019-07-07 14:02:42 · 463 阅读 · 0 评论 -
《算法竞赛进阶指南》 0x11 ~ 0x12 代码 + 杂谈
0x11 栈单调栈 栈的基本操作class MinStack {public: /** initialize your data structure here. */ int a[5050]; int mi[5050]; int tops; MinStack() { tops=0; } void ...原创 2019-07-06 15:12:08 · 870 阅读 · 0 评论 -
The Preliminary Contest for ICPC China Nanchang 南昌网络赛 A H I K M J题
A PERFECT NUMBER PROBLEMWrite a program to output the first 55 perfect numbers. A perfect number is defined to be a positive integer where the sum of its positive integer divisors excluding the numb...原创 2019-04-22 13:45:41 · 231 阅读 · 0 评论 -
{口胡~数据结构} CCCC L2-004 L2-006 L2-011 L2-012 L3-002(线段树) HRBUST-2040 L2-013(联通度)
L2-004 这是二叉搜索树吗? (25 分)口胡 搜索树中序遍历是有序的 树 左边小于右边 所以在前序遍历里一旦找到第一个比当前比较用的跟大的 便是右子树的开端这题 输入可能是镜像树的前序 所以 改下一开始建立树函数大小于号就好当 是镜像树时 显然 不能正常建立 所以后续遍历数组不会到达n个#include <bits/stdc++.h>using namespace ...原创 2019-03-02 21:17:09 · 226 阅读 · 0 评论 -
[线段树] CH4301 Can you answer on these queries III | 2019南昌网络赛 I Max answer | Interval GCD CH4302
https://www.acwing.com/problem/content/246/CH4301 Can you answer on these queries III这题改了好久啊问 区间子段和 最大显然一开始我们分成 lmax rmax lrmax 和 sum 一开始想的还行后面查询就是蛋疼的开始如同我注释的那个地方一样如果 我们直接返回 lrmax 我们就丢掉了一些信息这个...原创 2019-06-01 09:43:14 · 216 阅读 · 0 评论 -
2019 第十四届 中北大学ACM程序设计竞赛 题解
A.CQW又迟到了CQW是个坏学生,每天都迟到,从没看见他在第一节课出现过,懒惰的他,总是在点名的最后一刻出现。为了治一治他这个坏习惯,教C语言的XZW老师决定每天都给他布置一个单独的作业,并答应只要他每次都能正确完成作业就不点他的名字,CQW为了可以多睡觉,立刻答应了下来。为了让CQW知难而退,于是第一天XZW老师就布置了一个超级难的题!将一个字符串循环打印输出成一个 n * n 的矩阵。...原创 2019-05-15 14:10:08 · 2006 阅读 · 3 评论 -
[ 算法竞赛进阶指南 0x40 ] 杂谈
并查集[NOI2015]程序自动分析在实现程序自动分析的过程中,常常需要判定一些约束条件是否能被同时满足。考虑一个约束满足问题的简化版本:假设x1,x2,x3…代表程序中出现的变量,给定n个形如xi=xj或xi≠xj的变量相等/不等的约束条件,请判定是否可以分别为每一个变量赋予恰当的值,使得上述所有约束条件同时被满足。例如,一个问题中的约束条件为:x1=x2,x2=x3,x3=x4,x4≠x...原创 2019-05-28 21:26:00 · 225 阅读 · 0 评论 -
[ 算法竞赛进阶指南 0x00 ] 杂谈
持续更新。。。。约数之和分治 入门 极大的降低复杂度#include <bits/stdc++.h>#define fastio ios::sync_with_stdio(false);cin.tie(0)using namespace std;#define int long longtypedef long long ll;typedef pair<int, ...原创 2019-05-28 14:31:46 · 168 阅读 · 0 评论 -
[ 算法竞赛进阶指南 0x10 ] 杂谈
栈包含min函数的栈类似单调栈处理class MinStack {public: /** initialize your data structure here. */ int a[5050]; int mi[5050]; int tops; MinStack() { tops=0; } void ...原创 2019-05-28 17:41:31 · 263 阅读 · 0 评论 -
[扫描线] Atlantis POJ - 1151 | HDU - 1255 覆盖的面积 | POJ - 1177 Pictur
poj 1151扫描线#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>using namespace std;#define db doubleconst int maxn = 2005;struct node { double...原创 2019-05-30 15:51:56 · 152 阅读 · 0 评论 -
[区间计数(元素去重个数)] 树状数组(不变序列) 牛客练习赛47 | DongDong数颜色 HDU-3333 CF-703D
牛客练习赛47 | DongDong数颜色原创 2019-06-11 09:26:41 · 373 阅读 · 0 评论 -
《算法竞赛进阶指南》 0x14 ~ 0x16 代码 + 杂谈
哈希雪花hash表 做法#include <iostream>using namespace std;typedef long long ll;const int N = 100010;const int mod = 99991;int snow[N][7], head[N], nxt[N];int n, cnt;int H(int *a){ int ...原创 2019-07-07 15:44:56 · 514 阅读 · 0 评论 -
《算法竞赛进阶指南》 0x18 课后习题
括号画家括号匹配 stack 存下表 直接减就好#include <iostream>#include <cstring>#include <map>#include <stack>using namespace std;const string cd = "*(){}[]";map<char, int> id;...原创 2019-07-08 15:44:31 · 191 阅读 · 0 评论 -
《算法竞赛进阶指南》 0x45 ~ 0x48 代码 + 杂谈
点分治///淀粉质链接 : https://blog.csdn.net/qq_40831340/article/details/90234372平衡树theap 模板// treap模板题// 您需要写一种数据结构(可参考题目标题),来维护一些数,其中需要提供以下操作://插入x数//删除x数(若有多个相同的数,因只删除一个)//查询x数的排名(排名定义为比当前数小的数的个数+1...原创 2019-07-11 15:22:07 · 452 阅读 · 0 评论 -
《算法竞赛进阶指南》 0x08 课后习题
飞行员兄弟直接暴力枚举 2^16…#include <bits/stdc++.h>using namespace std;vector<int> yh[20];void init() { for(int i = 1; i <= 16; i ++ ) { yh[i].push_back(i); int t = i; while(-- t &...原创 2019-07-05 17:33:29 · 253 阅读 · 0 评论 -
《算法竞赛进阶指南》0x07 代码 + 杂谈
贪心orz 贪心和DP 快差不多一样难了Sunscreen直接贪 cow 按 l 升序 r 升序 排 spf 也升序排 这样 每个牛选最前面的尽量不挤还没的cow 就差不多了#include <bits/stdc++.h>using namespace std;const int maxn = 10005;struct node { int l, r; ...原创 2019-07-05 14:20:16 · 259 阅读 · 0 评论 -
《算法竞赛进阶指南》 0x42 ~ 0x43 代码 + 杂谈
树状数组楼兰图腾逆序对#include <bits/stdc++.h>using namespace std;typedef long long ll;const int maxn=2*1e5+10;int c[maxn];int n;int lowbit(int x) { return x&(-x);}int ask(int x) { int r...原创 2019-07-10 14:13:58 · 584 阅读 · 0 评论 -
《算法竞赛进阶指南》 0x05 ~ 0x06 代码 + 杂谈
排序原创 2019-07-04 14:31:37 · 295 阅读 · 0 评论 -
《算法竞赛进阶指南》 0x41 + 0x44 代码 + 杂谈
并查集普通并查集程序自动分析#include <bits/stdc++.h>using namespace std;const int maxn = 2e6 + 5;int n, m;int pre[maxn];void init(int n) { for(int i = 1; i <= n; i++) pre[i] = i;}...原创 2019-07-09 15:32:47 · 205 阅读 · 0 评论