自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(83)
  • 资源 (1)
  • 收藏
  • 关注

原创 c++构造函数

个人笔记

2023-03-02 21:37:36 486

原创 python的and和or以及c++的&&和||的区别

a and b 若a为False或0,则结果返回a 若a为True或非0,则结果返回b的值,无论b是什么类型a && b a或b有一个为false时返回false, 否则返回truea or b 若a为真,返回a的值,否则返回b的值a || b a或b有一个为真,则返回true, 否则返回false...

2022-01-12 22:04:46 433

原创 python实现字典的键值对互换的三种方法

原文作者:https://blog.csdn.net/u010614988/article/details/49337031/三种方式交换键值对(前提:值唯一):1.mydict={“a”:1,“b”:2,“c”:3}mydict_new={}for key,val in mydict.items():mydict_new[val]=key2.mydict={“a”:1,“b”:2,“c”:3}mydict_new=dict([val,key] for key,val in mydict.

2020-07-12 21:43:44 5762 1

原创 豆沙绿参数

豆沙绿的参数为:a. RGB颜色:199;237;204b. 十六位颜色代码:C7EDCCc. 色调:85;饱和度:123;亮度:205

2020-02-03 10:59:52 3490

原创 1119 Pre- and Post-order Traversals

题目链接:https://pintia.cn/problemsets/994805342720868352/problems/994805353470869504题意:根据前序遍历和后序遍历建树,输出中序遍历序列,序列可能不唯一,输出其中一个即可。  参考:https://www.cnblogs.com/chenxiwenruo/p/6131046.html 已知前序遍历和后序遍历序列,是无...

2020-02-03 10:31:38 222

原创 1129 Recommendation System

题目链接:https://pintia.cn/problemsets/994805342720868352/problems/994805348471259136题意:根据用户每次点击的东西的编号,输出他在点当前编号之前应该给这个用户推荐的商品的编号~只推荐k个~也就是输出用户曾经点击过的商品编号的最多的前k个~如果恰好两个商品有相同的点击次数,就输出编号较小的那个#include<bi...

2020-02-03 10:29:02 94

原创 1155 Heap Paths (30分)

题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/1071785408849047552题目大意:给出一颗完全二叉树,打印出从根节点到所有叶节点的路径,打印顺序先右后左,即先序遍历的镜像。然后判断该树是大顶堆、小顶堆或者不是堆~思路:dfs遍历,遇到叶子结点输出路径,用栈存路径#include<bits/st...

2020-01-10 22:09:00 147

原创 1148 Werewolf - Simple Version (20分)

题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/1038429808099098624题意:给定n名玩家,其中有两个狼人,其余为人类,所有玩家中恰有两人说谎,且说谎的人中一个是狼人一个是人类,现给出n个玩家的说法,编号从1到n,正数表示所指定的玩家为人类,负数表示所制定的玩家是狼人 。让你找出这两个狼人并按id从小到...

2020-01-10 22:01:13 117 1

原创 1016 Phone Bills (25)(25 分)

题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805493648703488参考博客:https://blog.csdn.net/cv_jason/article/details/81316244题目大意:给你一个长途电话收费标准,以及一张通话记录,计算每个客户的话费单。每张通话记录可能有不匹配的状况,你需...

2020-01-10 21:48:22 112

原创 1155 Heap Paths (30分)

题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/1071785408849047552题意:给出一颗完全二叉树,打印出从根节点到所有叶节点的路径,打印顺序先右后左,即先序遍历的镜像。然后判断该树是大顶堆、小顶堆或者不是堆~分析:1.深搜打印出所有路径(从右往左,即先序的镜像),通过push和pop回溯,维护路径2...

2020-01-09 18:47:40 100

原创 最大字段和(暴力,分治,在线算法)

求一个序列的最大字段和即求一个序列的最大连续字段和,例如[4, -3, 5, -2, -1, 2, 6, -2]的最大子段和为11=[4+(-3)+5+(-2)+(-1)+(2)+(6)]。1.暴力算法时间复杂度O(n^3)求出每一个子段的和取最大值...

2019-09-11 23:28:25 1822

原创 Fear Factoring Gym - 101652P (数论-除法分块)

题目链接:https://cn.vjudge.net/contest/323440#problem/C题意:定义F(x)为x的所有因子和,现在给你l,r,求l-r之内的所有F(i)的和。参考:https://blog.csdn.net/Healer66/article/details/82561234for(LL l = 1,r;l <= n;l = r + 1){ ...

2019-09-06 21:10:33 192

原创 Purple Rain Gym - 101652S & Max Sum(dp)

题目链接:https://cn.vjudge.net/contest/323440#problem/F题意:给出一串只包含’B’,'R’的字符串,让你找出一段区间使得在这段区间里面’R’和’B’的数量之差最大.和hdu1003这道题很相似,经典dp。hdu-1003 http://acm.hdu.edu.cn/showproblem.php?pid=1003#include<bit...

2019-09-06 20:03:10 162

原创 Codeforces Round #550 (Div. 3) F. Graph Without Long Directed Paths(染色bfs||dfs)

题目链接:http://codeforces.com/contest/1144/problem/F题意:给你一个无向图,让你把这个图变成有向图。这个有向图需要满足的是,从每一个结点出发到另一个结点。只能有一个路径长度。通俗讲,就是,如果A 结点 有一条路径到B 结点,那么B 结点就不能再有其他路径到其他结点去了。dfs代码#include<bits/stdc++.h>using...

2019-08-30 21:29:42 217

原创 Pots POJ - 3414(bfs+路径输出)

题目链接:https://cn.vjudge.net/contest/313994#problem/F思路:bfs需要输出路径,不能用c++的queue,因为回溯的过程要用到队列的下标,所以我们需要模拟队列#include<iostream>#include<cstdio>#include<cstring>#include<algorithm&g...

2019-08-24 21:56:23 264

原创 Prime Path POJ - 3126(筛素+bfs)

题目链接:https://cn.vjudge.net/contest/313994#problem/E#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<queue>using namespace std;bool ...

2019-08-24 21:46:00 127

原创 D - Find The Multiple POJ - 1426(dfs||bfs)

题目链接:https://cn.vjudge.net/contest/313994#problem/Ddfs或者bfs都可以,dfs最多20层(打表)bfs代码#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<queue&g...

2019-08-24 21:34:45 172

原创 Dungeon Master POJ - 2251(广搜三维)

题目链接:https://cn.vjudge.net/contest/313994#problem/B就是多加一维,其他没啥#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<stac...

2019-08-24 21:05:15 77

原创 棋盘问题 POJ - 1321(搜索dfs)

题目链接:https://cn.vjudge.net/contest/313994#problem/A题意:给定一个不规则的棋盘,往这个棋盘里摆放K个棋子,求棋子的最大摆放组合数。思路:定义一个标记列的数组,因为dfs的过程是从上往下相当于一个标记数组#include<iostream>#include<cstdio>#include<cstring>...

2019-08-24 21:00:38 134

原创 I - I Will Go Gym - 101875I(dfs序)

题目链接:https://cn.vjudge.net/contest/315987#problem/I题意:N个人要参加一个局,每个人有自己的好朋友,如果他的好朋友来,他才有可能来。N个人的关系不够成环。Q次查询,问若x来了,y是否肯定来。分析:若点y是x的祖先,则y肯定回来。一次dfs确定每个点覆盖的区间,若点x的dfs序在y的覆盖区间内,则y肯定会来。#include<iostre...

2019-08-24 20:31:25 217

原创 A - A water problem HDU - 5832(模拟除法)

Two planets named Haha and Xixi in the universe and they were created with the universe beginning.There is 73 days in Xixi a year and 137 days in Haha a year.Now you know the days Nafter Big Bang, ...

2019-08-24 20:24:35 100

原创 Max Sum Plus Plus hdu-1024(动态规划+m子段和的最大值)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1024参考:https://www.cnblogs.com/kuangbin/archive/2011/08/04/2127085.htmlhttps://blog.csdn.net/codeswarrior/article/details/80310401题目大意:输入一个m,n分别表示成m组,...

2019-08-23 09:20:55 168

原创 Tri Tiling hdu-1143(递推,铺方格)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1143参考:https://blog.csdn.net/M17865923255/article/details/49510375首先n是奇数4的时候,方法数是0,。所以如果用f[i] (i 为偶数) 表示3Xi的方格铺满骨牌的方案数。但是f[i]不可能由f[i-1]递推过来,所以我们猜想可能跟f...

2019-08-21 09:41:35 156

原创 Teamwork Gym - 101492E(基础dp)

题目链接;https://cn.vjudge.net/contest/319592#problem/E题意:在一个夜黑风高的晚上,有n(n <= 50)个小朋友在桥的这边,现在他们需要过桥,但是由于桥很窄,每次只允许不大于两人通过,他们只有一个手电筒,所以每次过桥的两个人需要把手电筒带回来,i号小朋友过桥的时间为T[i],两个人过桥的总时间为二者中时间长者。问所有小朋友过桥的总时间最短是多...

2019-08-21 08:25:14 89

原创 Gym - 101490D Bridge Automation(递推,思维)

题目链接:https://vjudge.net/problem/Gym-101490D 参考:https://blog.csdn.net/Richie_ll/article/details/77946371题意:由一个桥,有n艘船需要从桥下面过去,对于桥来说,桥升起来需要60秒,降下去需要60秒,对于每艘船来说,必须等到桥完全升起才能通过,通过时间是20秒,如果桥此刻没有升起来,船最多只能等3...

2019-08-20 16:40:06 128

原创 Wormholes(负权环判定)

题目:https://cn.vjudge.net/contest/313997#problem/F参考:https://blog.csdn.net/qq_36424540/article/details/77780930题意概括:  有一个人有n块农田和m条连接农田的道路,走每段路都需要花费一定的时间,同时他还非常热衷于时间穿梭。他想要到达某一块农田后能够通过虫洞穿越回他从起点出发之前的时间...

2019-08-19 10:14:01 130

原创 E - 【粉色】浣熊市下水道 Gym - 102072K(bfs,可移动障碍物)

##&##&*#一单位时间后##&AL#&##&####*#二单位时间后##&A##&#L&*#三单位时间后##&A##&##&##L#*#四单位时间后##&A##&##&*##L##里昂如果再向左走的话就会跟僵尸碰个正着,而且不论里昂怎么往...

2019-08-17 22:40:15 132

原创 K - Assigning Frequencies UVALive - 8273(dfs暴力)

题意是:,往这个图中的点放置频率,总共有三种频率,如果这两个点连通,并且频率一样,则与题目不符,反之任意两个连通的点频率都要不一样;思路:dfs暴力枚举#include<bits/stdc++.h>using namespace std;int mp[30][30];int vis[30];int n, m;int dfs(int now){ for(int i...

2019-08-17 22:33:07 174

原创 C. Good String

Let’s call (yet again) a string good if its length is even, and every character in odd position of this string is different from the next character (the first character is different from the second, t...

2019-08-17 21:15:17 183

原创 Wireless Network(并查集)

An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock attacked, all computers in the n...

2019-08-17 10:45:50 215

原创 Currency Exchange(判断正权回路)

Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There can...

2019-08-16 15:06:52 1338

原创 Til the Cows Come Home(最短路裸题)

Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she wants to get b...

2019-08-16 14:20:27 138

原创 Silver Cow Party(迪杰斯特拉+转置矩阵)

One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1…N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total of M (1 ≤ M ≤ 100,000) unidirectional (one-way roa...

2019-08-16 11:14:25 94

原创 Heavy Transportation(最短路)Dijkstra+SPFA

BackgroundHugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his cust...

2019-08-16 10:41:15 158

原创 H - Half Nice Years Gym - 101840H

Salah is really optimistic about the qualification of the Egyptian football team for the world cup 2018.He was thinking deeply about why it didn’t happen often that the Egyptian team qualified to the...

2019-08-15 21:00:48 275

原创 D - Dream Team Gym - 101840D

Before the World Cup, we would like to form the ultimate dream team. The team that will win againstall teams. We have a big group of the top N players in the world, where each player has a numberrep...

2019-08-15 20:22:28 392

原创 C. Alarm Clocks Everywhere(欧几里得算法简单应用)

Ivan is going to sleep now and wants to set his alarm clock. There will be many necessary events tomorrow, the ii-th of them will start during the xixi-th minute. Ivan doesn’t want to skip any of the ...

2019-08-13 20:53:53 200

原创 简单差分

简单差分可能这里的阅读体验更好:https://www.zybuluo.com/Junlier/note/1232395引入首先,给出一个问题:给出n个数,再给出Q个询问,每个询问给出le,ri,x,要求你在le到ri上每一个值都加上x,而只给你O(n)的时间范围,怎么办?思考一下:如果暴力,卡一下le和ri,随随便便让你O(n^2)T成狗。用线段树或树状数组搞一搞,抱歉,这个复杂度...

2019-08-09 21:28:46 197

原创 C. Array Splitting(差分)

You are given a sorted array a1,a2,…,an (for each index i>1 condition ai≥ai−1 holds) and an integer k.You are asked to divide this array into k non-empty consecutive subarrays. Every element in th...

2019-08-09 21:01:48 425

原创 G - Ancient Go HDU - 5546(BFS)

Yu Zhou likes to play Go with Su Lu. From the historical research, we found that there are much difference on the rules between ancient go and modern go.Here is the rules for ancient go they were pla...

2019-08-08 21:29:26 250

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除