- 博客(114)
- 收藏
- 关注
原创 UPC12798 FZB
题目链接题目描述Hja有一棵N个点的树,树上每个点有点权,每条边有颜色。一条路径的权值是这条路径上所有点的点权和,一条合法的路径需要满足该路径上任意相邻的两条边颜色都不相同。问这棵树上所有合法路径的权值和是多少。输入第一行一个数N。接下来一行N个数代表每个点的权值。接下来N−1行每行三个整数s,e,c,代表s到e之间有一条颜色为c的边。输出一行一个整数代表答案。样例输入6...
2020-04-10 14:14:00
89
原创 真二叉树重构(Proper Rebuild)
真二叉树重构(Proper Rebuild)DescriptionIn general, given the preorder traversal sequence and postorder traversal sequence of a binary tree, we cannot determine the binary tree.Figure 1In Figure 1...
2019-09-18 14:47:00
438
原创 重名剔除(Deduplicate)
重名剔除(Deduplicate)DescriptionMr. Epicure is compiling an encyclopedia of food. He had collected a long list of candidates nominated by several belly-gods. As candidates in list are nominated by...
2019-09-18 14:47:00
902
原创 祖玛(Zuma)
祖玛(Zuma)DescriptionLet's play the game Zuma!There are a sequence of beads on a track at the right beginning. All the beads are colored but no three adjacent ones are allowed to be with a same...
2019-09-18 14:47:00
1336
原创 玩具(Toy)
玩具(Toy)DescriptionZC God is best at logical reasoning. One day, he talks about his childhood digital toys.The toy is like a Rubik's cube, but not a Rubik's cube. Specifically, it is not a 3 *...
2019-09-18 14:46:00
905
原创 无线广播(Broadcast)
无线广播(Broadcast)DescriptionA broadcaster wants to set up a radio broadcast transmitter in an area. There are n towns in the area, and each town has a transmitter installed and plays its own pro...
2019-09-18 14:46:00
1065
原创 循环移位(Cycle)
循环移位(Cycle)DescriptionCycle shifting refers to following operation on the sting. Moving first letter to the end and keeping rest part of the string. For example, apply cycle shifting on ABCD w...
2019-09-18 14:46:00
788
原创 旅行商(TSP)
旅行商(TSP)DescriptionShrek is a postman working in the mountain, whose routine work is sending mail to n villages. Unfortunately, road between villages is out of repair for long time, such that ...
2019-09-18 14:45:00
410
原创 平均气温(Temperature)
平均气温(Temperature)DescriptionA weather station collects temperature data from observation stations all over the country every day, and provides statistical inquiry services to remote users thro...
2019-09-18 14:45:00
2400
2
原创 任务调度(Schedule)
任务调度(Schedule)DescriptionA HPS cluster is equipped with a unique task scheduler. To be simple, it is assumed that this cluster doesn’t support multiple tasks running at the same time, such tha...
2019-09-18 14:45:00
833
原创 灯塔(LightHouse)
灯塔(LightHouse)DescriptionAs shown in the following figure, If another lighthouse is in gray area, they can beacon each other.For example, in following figure, (B, R) is a pair of lighthouse ...
2019-09-18 14:44:00
758
原创 范围查询(Range)
范围查询(Range)DescriptioinLet S be a set of n integral points on the x-axis. For each given interval [a, b], you are asked to count the points lying inside.InputThe first line contains two inte...
2019-09-18 14:44:00
1272
原创 列车调度(Train)
列车调度(Train)DescriptionFigure 1 shows the structure of a station for train dispatching.Figure 1In this station, A is the entrance for each train and B is the exit. S is the transfer end. All...
2019-09-18 14:44:00
543
原创 洛谷P2774 方格取数问题
洛谷P2774方格取数问题题目链接将题目反着考虑,假设现在所有数都取,需要删掉一部分数,使得剩下的数没有公共边且删掉的数之和最小。容易发现,两个位置有公共边当且仅当他们横纵坐标的和的奇偶性不同。建立一个二分图,左边为坐标和为奇数的点,右边为坐标和为偶数的点,将左右两边存在公共边的点连起来。s向左边的每个点建边,权值为点的权值,右边每个点向t建边,权值也为点的权值。求删掉和最少的数使...
2019-09-11 20:18:00
202
原创 洛谷P4009骑车加油行驶问题(分层图、最小费用最大流)
洛谷P4009骑车加油行驶问题题目链接建一个\(k+1\)层的图,第0层为到加油站,第\(i\) \((1\leq i \leq k)\)层为走了\(i\)步,每个点向下一层中与它四联通的点建流量为1花费为0的边。需要注意它只要经过加油站就必须要加油,所以在1到k层中,加油站的点只能向第0层建边,不可向下一层建边#include <bits/stdc++.h>usi...
2019-09-10 17:20:00
217
原创 HDU4081 Qin Shi Huang's National Road System
#include <bits/stdc++.h>using namespace std;const int MAXN = 1100;const int INF = 147483647;bool vis[MAXN];double lowc[MAXN];int pre[MAXN];double MAX[MAXN][MAXN];bool used[MAXN][MA...
2019-09-02 22:50:00
203
原创 CCPC 2018 秦皇岛 A题 Build(网络流、限制花费的最小费用最大流)
CCPC 2018 秦皇岛 A题 Build(网络流、限制花费的最小费用最大流)题意:给一个无向图,给出每条边的容量和单位花费,求从1到n费用不超过f的最大流如果当次spfa跑出来的流量已经不能全部买到了,那就切一部分买到的。#include <bits/stdc++.h>using namespace std;const int maxn = 2100;co...
2019-08-31 11:01:00
299
原创 记录deepin设置自动代理
记录deepin设置自动代理sudo apt install python3-pipsudo pip3 install genpacgenpac --pac-compress --pac-proxy 'SOCKS5 127.0.0.1:1080' --format pac -o ~/auto.pac然后在deppin的 设置-网络-系统代理-自动 填入pac文件的位置...
2019-08-08 21:39:09
1478
原创 UVA 11019 - Matrix Matcher(二维hash)
UVA 11019 - Matrix Matcher#include <bits/stdc++.h>using namespace std;#define rint register int#define rll register long longtypedef long long ll;const int maxn = 1e3 + 100;const in...
2019-08-08 09:47:00
221
原创 UVA 12467 - Secret Word
UVA 12467 - Secret Wordkmp+二分,二分枚举答案的长度,用kmp判断是否合法#include <bits/stdc++.h>using namespace std;#define rint register int#define rll register long long#define long long llconst int ma...
2019-08-07 10:33:00
356
原创 UVA 12604 - Caesar Ciphe
UVA 12604 - Caesar Cipher题意:给一个字母表s,一个标准串w,一个密文s,问w是否可能在密文的原文中出现且仅出现一次#include <bits/stdc++.h>using namespace std;const int maxn = 6e5;char a[maxn], b[maxn], o[maxn];int c[300];int pi[m...
2019-08-06 10:13:00
474
原创 UVA 11452 Dancing the Cheeky-Cheeky
UVA 11452 "Dancing the Cheeky-Cheeky"找循环节那里要从后往前找,以解决112234112234这样的数据#include <bits/stdc++.h>using namespace std;const int maxn = 10000;char a[maxn];int pi[maxn];void getnext(int n) {...
2019-08-04 21:00:00
222
原创 UVA 11022 String Factoring
UVA 11022 "String Factoring"dp[l] [r] = min(dp[l] [i],dp[i+1] [r] ) \(l\le i < r\)#include <bits/stdc++.h>using namespace std;const int maxn = 1000;char a[maxn];int f[100][100], pi[ma...
2019-08-04 20:26:00
391
原创 UVA 455 Periodic Strings(前缀数组)
UVA 455 "Periodic Strings"题意:给T个字符串,分别输出这T个字符串的最小循环节长度求出前缀数组如果n-pi[n]整除n,则答案为n-pi[n],否则为答案为n。如上图,如果红色的前缀与蓝色的后缀相同,则两段绿色的相同,以此类推,整个字符串可划分为n-pi[n]段相同的子串#include <bits/stdc++.h>using namespac...
2019-08-04 15:32:00
119
原创 P3358 最长k可重区间集问题
P3358 最长k可重区间集问题题目链接#include <bits/stdc++.h>using namespace std;typedef pair<int, int> P;struct edge { int to, cap, cost, rev; edge(int a, int b, int c, int d) ...
2019-08-02 23:03:00
163
原创 Tenka1 Programmer Contest 2019 E - Polynomial Divisors
题目链接参考博客关于check()函数,相隔p-1取出来,提出一个公因数后,剩下的为\(x^{p-1},x^{2*(p-1)}…x^{n*(p-1)}\),x与p互质,各项的幂取余p的欧拉函数为0。#include "bits/stdc++.h" using namespace std;typedef long long ll;const int mod = 1e9 + 7;con...
2019-07-29 19:35:00
173
原创 2019牛客暑期多校训练营(第三场)D Big Integer
题目链接比赛的时候找到d之后就卡住了,不知道怎么找\(i^j\)中有多少个d的倍数,没有想到可以先固定j,然后看对于当前j有多少个i快速幂的时候long long 溢出了……#include "bits/stdc++.h"using namespace std;typedef long long ll;ll mod;ll powmod(ll a, ll b) { ll ...
2019-07-26 14:00:00
170
原创 ZOJ2432 Greatest Common Increasing Subsequence(最长公共上升子序列)
Greatest Common Increasing SubsequenceTime Limit: 2 Seconds Memory Limit: 65536 KB Special JudgeYou are given two sequences of integer numbers. Write a program to determine their common increasing s...
2019-07-19 11:10:00
145
原创 UPC11456 视线(计算几何)
UPC11456 视线(计算几何) 视线时间限制: 1 Sec 内存限制: 128 MB提交: 21 解决: 2[提交] [状态] [命题人:admin]题目描述二维平面上,原点处有一个半径为R的圆。平面上有N个点,保证没有点在圆上或圆内,保证任意两个点不与圆相切,求互相可以看见的点的对数。看见:对于两个点(x1,y1)和(x2,...
2019-05-22 19:24:00
181
原创 上海市高校大学生程序设计邀请赛 C:小花梨判连通
上海市高校大学生程序设计邀请赛 C:小花梨判连通 Problem C、小花梨判连通时间限制:2000ms 空间限制:512MBDescription小花梨给出
2019-05-18 19:27:00
166
原创 洛谷P5300 与或和(全1子矩阵/单调栈)
洛谷P5300 与或和(全1子矩阵/单调栈) 洛谷P5300 与或和题目链接按照二进制将矩阵转换为32个01矩阵,and和就是一个01矩阵中全1子矩阵的个数乘以当前矩阵的贡献值,or和就是(总子矩阵个数-全0子矩阵的个数)*当前矩阵的贡献值。#include "bits/stdc++.h"using namespace std;type...
2019-05-15 09:56:00
223
原创 2019山东ACM省赛K题 zoj4123 Happy Equation
2019山东ACM省赛K题 zoj4123 Happy Equation Happy Equation Time Limit: 1 Second Memory Limit: 65536 KBLittle Sub has just received an equation, which is shown below, as his birthd...
2019-05-14 21:58:00
272
原创 2019山东ACM省赛总结
2019山东ACM省赛总结 2019山东ACM省赛总结一、省赛总结 总的来说,这次比赛我们的发挥还是挺好的,比平时训练的状态要好,全程出题较快且仅产生20分钟罚时,也正是这样我们才能成为唯一一个七题拿金的队伍。在收获的同时,这次比赛也暴露出我们的一些问题。平时踩更多的坑,赛场才能少踩坑: 在平日的训练中,我们三个的成绩几乎每次都是最差的,...
2019-05-13 17:07:00
269
原创 CCPC2018 桂林 A: Array Merge(贪心、带权并查集合并)
CCPC2018 桂林 A: Array Merge(贪心、带权并查集合并) 时间限制:1 Sec内存限制:128 MB提交:37解决:3[提交] [状态] [命题人:admin]题目描述Given two arrays A, B of length n and m separately, you have to merge...
2019-05-02 17:34:00
659
原创 temp
temp g = gcd(a+k,b+k),设 a+k = g*x,b + k = g*y,则g(x-y) = a-b, 所以 g|(a-b),枚举a-b的所有约数,按照题意取出最小答案#include "bits/stdc++.h"using namespace std;typedef long lon...
2019-04-25 00:26:00
134
原创 BZOJ 1013 球形空间产生器(高斯消元)
BZOJ 1013 球形空间产生器(高斯消元) 时间限制:1 Sec内存限制:128 MB提交:11解决:7[提交] [状态] [命题人:admin]题目描述有一个球形空间产生器能够在n维空间中产生一个坚硬的球体。现在,你被困在了这个n维球体中,你只知道球面上n+1个点的坐标,你需要以最快的速度确定这个n维球体的球心坐标,以...
2019-04-23 17:06:00
186
原创 BZOJ 2973 石头游戏(矩阵构造,矩阵快速幂)
BZOJ 2973 石头游戏(矩阵构造,矩阵快速幂) 时间限制:1 Sec内存限制:128 MB提交:5解决:4[提交] [状态] [命题人:admin]题目描述石头游戏在一个 n 行 m 列 (1≤n,m≤8) 的网格上进行,每个格子对应一种操作序列,操作序列至多有10种,分别用0~9这10个数字指明。操作序列是一个长度不...
2019-04-21 20:47:00
292
原创 POJ 3233 Matrix Power Series (矩阵乘法,分块矩阵)
POJ 3233 Matrix Power Series (矩阵乘法,分块矩阵) 时间限制:1 Sec内存限制:128 MB提交:27解决:6[提交] [状态] [命题人:admin]题目描述Given a n × n matrix A and a positive integer k, find the sum S = A...
2019-04-19 16:24:00
178
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人