自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

tomjobs的博客

别慌,问题很大,慌也没用。

  • 博客(1665)
  • 论坛 (1)
  • 收藏
  • 关注

原创 再见2020(ACM退役倒计时)

总结一下自己的2020:1000+的博客3个cf紫名湖南省赛2等奖蓝桥杯国一省一天梯赛国一省一CCPC威海铜加上乱七八糟企业比赛的奖最终ICPC济南完成了大一的心愿rk50+拿到了银牌(差2个多小时就金了呜呜呜,顺便后面3天考试喜提挂科)哦对了,还找到个愿意带我学习的大佬@陈炸炸All Was Ended...

2020-12-27 17:19:48 222 5

原创 The Csust Cat named HASH

HASH

2020-11-10 15:35:55 128 3

原创 About Me

Hello World

2020-08-07 00:08:05 367 2

原创 菜鸡的2020训练日志

训练记录前言√ 代表赛中ACX 代表尝试但是没过O 代表没有AC但是补了题号的超链接代表题解地址,如果是有点想法但是暂时没过的,会写到后面。1. ICPC NEAU Programming Contest 2020链接:https://www.jisuanke.com/contest/9342/challenges题号情况题解A——B——CO计算几何D√单调栈直接可以求,你也可以结合倍增,强制在线的时候就只能倍增了EX

2020-06-06 23:00:00 576

原创 BZOJ 4033. [HAOI2015]树上染色(树形DP,边贡献)

Description有一棵点数为N的树,树边有边权。给你一个在0~N之内的正整数K,你要在这棵树中选择K个点,将其染成黑色,并将其他的N-K个点染成白色。将所有点染色后,你会获得黑点两两之间的距离加上白点两两之间距离的和的收益。问收益最大值是多少。Input第一行两个整数N,K。接下来N-1行每行三个正整数fr,to,dis,表示该树中存在一条长度为dis的边(fr,to)。输入保证所有点之间是联通的。N<=2000,0<=K<=NOutput输出一个正整数,表示收益

2021-01-19 15:55:19 3

原创 BZOJ 1040. [ZJOI2008]骑士(基环树DP,没有上司的舞会加强版)

Description  Z国的骑士团是一个很有势力的组织,帮会中汇聚了来自各地的精英。他们劫富济贫,惩恶扬善,受到社会各界的赞扬。最近发生了一件可怕的事情,邪恶的Y国发动了一场针对Z国的侵略战争。战火绵延五百里,在和平环境中安逸了数百年的Z国又怎能抵挡的住Y国的军队。于是人们把所有的希望都寄托在了骑士团的身上,就像期待有一个真龙天子的降生,带领正义打败邪恶。骑士团是肯定具有打败邪恶势力的能力的,但是骑士们互相之间往往有一些矛盾。每个骑士都有且仅有一个自己最厌恶的骑士(当然不是他自己),他是绝对不

2021-01-19 12:48:51 7

原创 LeetCode 25. K 个一组翻转链表(递归)

思路:每kkk个进行一次链表反转(这个可以递归解决),然后将反转后链表的头结点连接到后面的节点。同时利用快慢指针,保证快指针比慢指针多kkk个节点,用以辅助翻转操作。/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x).

2021-01-18 22:43:58 9

原创 LeetCode 206. 反转链表

反转一个单链表。示例:输入: 1->2->3->4->5->NULL输出: 5->4->3->2->1->NULL/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class

2021-01-18 19:01:36 12

原创 LeetCode 24. 两两交换链表中的节点

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : val(x), next(next.

2021-01-18 18:01:52 5

原创 LeetCode 23. 合并K个升序链表(分治 / 堆)

思路:分治:分为两部分分别求解,再把求解结果按照两个链表合并的方式合并。堆:将所有的节点放入堆中,每次取最小权值的节点。分治:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nul.

2021-01-18 17:15:32 24

原创 LeetCode 21. 合并两个有序链表

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : val(x), next(next.

2021-01-18 15:15:44 7

原创 LeetCode 19. 删除链表的倒数第N个节点(快慢指针)

给定一个链表,删除链表的倒数第 n 个节点,并且返回链表的头结点。示例:给定一个链表: 1->2->3->4->5, 和 n = 2.当删除了倒数第二个节点后,链表变为 1->2->3->5.说明:给定的 n 保证是有效的。进阶:你能尝试使用一趟扫描实现吗?思路:定义两个指针,先让快指针走nnn步,然后两个指针一起走直到快指针走到终点。/** * Definition for singly-linked list. * struct List

2021-01-18 15:08:17 5

原创 2018ICPC南京 Problem I. Magic Potion(最大流)

题意:nnn个人,每个人有一个列表,可以杀掉列表里面的一只怪兽,每只怪兽只能死一次。有kkk瓶药水,可以让一个人多杀一只怪兽。求最多可以杀多少只怪兽。思路:最大流裸题,只是再熟悉一下板子。#include <cstdio>#include <cstring>#include <algorithm>#include <map>#include <cmath>#include <unordered_map>#inc.

2021-01-18 14:44:20 6

原创 2018ICPC 南京 Problem D. Country Meow(模拟退火)

思路:裸的最小球覆盖,直接模拟退火写。#include <bits/stdc++.h>using namespace std;const int maxn = 1050;const int inf = 0x3f3f3f3f;const double delta = 0.98;const double eps = 1e-7;struct Point { double x,y,z;}a[maxn];int n;double dist(Point a,Point b){.

2021-01-17 23:26:54 8

原创 2018南京ICPC Problem K. Kangaroo Puzzle(乱搞)

题意:一些位置有人,一些位置是墙。你可以将所有人往一个方向移动,除非是边界或者是墙才不能移动。至多50000步将所有人移动到一个地方。思路:直接随机取方向,区域赛也搞逗你玩的题目么。。。#include <cstdio>#include <cstring>#include <algorithm>#include <map>#include <cmath>#include <unordered_map>#include

2021-01-17 22:53:31 6

原创 2018ICPC南京 Problem M. Mediocre String Problem(回文串,马拉车,扩展KMP)

题意:给你两个字符串s,ts,ts,t,要求从sss中找到一个子串和ttt的一个前缀拼起来,结果要是回文串。求多少种拼法。思路:借此题复习了一下字符串算法。首先sss中找到的子串可以分为两部分:s1+s2s1+s2s1+s2,s1s1s1一定是ttt一个前缀的逆反串,s2s2s2一定是个回文串。所以可以将一开始所给的sss串反一下,然后算出每个右端点iii对应回文串的个数,再找到[i+1,len][i+1,len][i+1,len]部分与ttt串的最长公共前缀,二者相乘就是答案。算回文串的过程.

2021-01-17 22:39:48 9

原创 Codeforces-1473 F. Strange Housing(贪心,染色)

Students of Winter Informatics School are going to live in a set of houses connected by underground passages. Teachers are also going to live in some of these houses, but they can not be accommodated randomly. For safety reasons, the following must hold:A

2021-01-17 18:09:17 16

原创 Codeforces-1473 E - Strange Shuffle(交互,巧妙)

This is an interactive problem.???? people sitting in a circle are trying to shuffle a deck of cards. The players are numbered from 1 to ????, so that players ???? and ????+1 are neighbours (as well as players 1 and ????). Each of them has exactly ???? ca

2021-01-17 18:01:23 11

原创 Codeforces-1471 D. Strange Definition(哈希,质因数分解)

Let us call two integers ???? and ???? adjacent if ????????????(????,????)????????????(????,????) is a perfect square. For example, 3 and 12 are adjacent, but 6 and 9 are not.Here ????????????(????,????) denotes the greatest common divisor (GCD) of intege

2021-01-17 17:38:10 21

原创 Codeforces-1473 C - Strange Birthday Party

Petya organized a strange birthday party. He invited ???? friends and assigned an integer ???????? to the ????-th of them. Now Petya would like to give a present to each of them. In the nearby shop there are ???? unique presents available, the ????-th pres

2021-01-17 17:27:49 14

原创 Codeforces-1471 B. Strange List

You have given an array ???? of length ???? and an integer ???? to a brand new robot. What the robot does is the following: it iterates over the elements of the array, let the current element be ????. If ???? is divisible by ????, the robot adds ???? copie

2021-01-17 17:23:42 11

原创 Codeforces-1471 A. Strange Partition

You are given an array ???? of length ????, and an integer ????. You can perform the following operation as many times as you would like (possibly zero): replace two adjacent elements of the array by their sum. For example, if the initial array was [3,6,9]

2021-01-17 17:21:07 12

原创 Leetcode周赛224

leetcode周赛224https://leetcode-cn.com/contest/weekly-contest-224/难度顺序:A≤B≤C≤DA\le B\le C\le DA≤B≤C≤D。代码分为头文件和Solution主体部分,头文件在文末。A.可以形成最大正方形的矩形数目提示:1 <= rectangles.length <= 1000rectangles[i].length == 21 <= li, wi <= 10^9li != wi思路:

2021-01-17 14:27:55 31

原创 Codeforces-1473 E. Minimum Path(分层图(多维)最短路)

题意:一条路径的花费为求1点到其他所有点路径的最小花费。思路:每个路径可以分出两种操作:减掉一条边,加上一条边。那么定义dis[i][0/1][0/1]dis[i][0/1][0/1]dis[i][0/1][0/1]代表1到iii路径的最小花费,以及包括第一次操作的使用情况,第二次操作的使用情况。然后就dijdijdij转移就好了。#include <cstdio>#include <cstring>#include <algorithm>#inclu

2021-01-16 20:08:39 22

原创 Codeforces-1473 D. Program(前缀和)

You are given a program that consists of ???? instructions. Initially a single variable ???? is assigned to 0. Afterwards, the instructions are of two types:increase ???? by 1;decrease ???? by 1.You are given ???? queries of the following format:query

2021-01-16 20:04:31 53

原创 Codeforces-1473 C. No More Inversions(回文串逆序数)

You have a sequence ???? with ???? elements 1,2,3,…,????−1,????,????−1,????−2,…,????−(????−????) (????≤????<2????).Let’s call as inversion in ???? a pair of indices ????<???? such that ????[????]>????[????].Suppose, you have some permutation ???

2021-01-16 20:01:17 39

原创 Codeforces-1473 B. String LCM

Let’s define a multiplication operation between a string ???? and a positive integer ????: ????⋅???? is the string that is a result of writing ???? copies of ???? one after another. For example, “abc” ⋅ 2 = “abcabc”, “a” ⋅ 5 = “aaaaa”.A string ???? is div

2021-01-16 19:42:39 63

原创 Codeforces-1473 A. Replacing Elements

You have an array ????1,????2,…,????????. All ???????? are positive integers.In one step you can choose three distinct indices ????, ????, and ???? (????≠????; ????≠????; ????≠????) and assign the sum of ???????? and ???????? to ????????, i. e. make ?????

2021-01-16 19:39:11 25

原创 Acwing 360. Freda的传呼机(仙人掌图重构,lca)

为了随时与rainbow快速交流,Freda制造了两部传呼机。Freda和rainbow所在的地方有N座房屋、M 条双向光缆。每条光缆连接两座房屋,传呼机发出的信号只能沿着光缆传递,并且传呼机的信号从光缆的其中一端传递到另一端需要花费t单位时间。现在Freda要进行Q次试验,每次选取两座房屋,并想知道传呼机的信号在这两座房屋之间传递至少需要多长时间。N座房屋通过光缆一定是连通的,并且这M条光缆有以下三类连接情况:A:光缆不形成环,也就是光缆仅有N-1 条。B:光缆只形成一个环,也就是光缆仅有N 条

2021-01-16 14:04:32 14

原创 Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths CodeForces - 741D(启发式合并,回文串)

Just in case somebody missed it: we have wonderful girls in Arpa’s land.Arpa has a rooted tree (connected acyclic graph) consisting of n vertices. The vertices are numbered 1 through n, the vertex 1 is the root. There is a letter written on each edge of t

2021-01-14 14:52:54 19

原创 Codeforces-1467 E. Distinctive Roots in a Tree(dfs序,树上差分)

You are given a tree with ???? vertices. Each vertex ???? has a value ???????? associated with it.Let us root the tree at some vertex ????. The vertex ???? is called a distinctive root if the following holds: in all paths that start at ???? and end at som

2021-01-12 21:51:50 55

原创 Codeforces-1467 D. Sum of Paths(记忆化搜索)

There are ???? cells, numbered 1,2,…,???? from left to right. You have to place a robot at any cell initially. The robot must make exactly ???? moves.In one move, the robot must move one cell to the left or right, provided that it doesn’t move out of boun

2021-01-12 21:43:02 28

原创 Codeforces-1467 C. Three Bags

You are given three bags. Each bag contains a non-empty multiset of numbers. You can perform a number of operations on these bags. In one operation, you can choose any two non-empty bags, and choose one number from each of the bags. Let’s say that you choo

2021-01-12 21:39:19 51

原创 Codeforces-1467 B. Hills And Valleys

You are given a sequence of ???? integers ????1, ????2, …, ????????. Let us call an index ???? (2≤????≤????−1) a hill if ????????>????????+1 and ????????>????????−1; and let us call it a valley if ????????<????????+1 and ????????<????????−1.Le

2021-01-12 21:33:45 32

原创 Codeforces-1467 A. Wizard of Orz

There are ???? digital panels placed in a straight line. Each panel can show any digit from 0 to 9. Initially, all panels show 0.Every second, the digit shown by each panel increases by 1. In other words, at the end of every second, a panel that showed 9

2021-01-12 21:27:15 34

原创 2020ICPC济南 Bit Sequence(数位DP)

思路:赛中最后3min过的,过的时候都直接叫出来了(虽然还是银,对结果并没有影响定义dp[len][one][sta][sum]dp[len][one][sta][sum]dp[len][one][sta][sum],代表遍历到了第iii位,第[8,len][8,len][8,len]位oneoneone的个数为奇数/偶数,第[0,7][0,7][0,7]位选择的值,以及第8位开始连续1的个数的奇偶值sumsumsum。复杂度O(T∗60∗2∗2∗27)O(T*60*2*2*2^7)O(T∗60∗..

2021-01-11 23:57:13 36

原创 2020ICPC 济南 A. Matrix Equation(异或高斯消元)

思路:反正感觉挺有意思的一道题目,赛中想到高斯消元觉得没有板子写不了。然后队友说kuangbin板子有,我就敲上去,就过了。。。具体过程懒得说了,反正你把方程列出来变形一下,发现ccc矩阵的每一列是独立的,所以按照列来算。对于每一列可以得到一个nnn个变量的异或矩阵,结果就是2高斯消元后自由元个数2^{高斯消元后自由元个数}2高斯消元后自由元个数,每一列结果乘起来就好了。#include <cstdio>#include <cstring>#include <al.

2021-01-11 23:09:30 12

原创 2020济南ICPC J.Tree Constructer(二分图,构造)

思路:能想到二分图就感觉挺简单的了。将树染色成二分图,然后取数目较小的那一部分(保证数目不大于50)。对于第一种颜色:将第iii个节点染色成(1<<60)−1−(1<<59)−(1<<i)(1<<60)-1-(1<<59)-(1<<i)(1<<60)−1−(1<<59)−(1<<i),这样保证同色或运算结果不会是(1<<60)−1(1<<60)-1(1<<6.

2021-01-11 23:03:27 25

原创 LeetCode 32. 最长有效括号(DP)

思路:很裸的DP。定义dp[i]dp[i]dp[i]代表以第iii个字符结尾所能得到的最长连续合法括号串。那么只存在两种转移:第iii个字符是右括号,和第i−1i-1i−1个字符结尾的合法串拼起来(dp[i−1]dp[i-1]dp[i−1]),再拼左边一个左括号。dp[i] = max(dp[i],dp[i - 1] + 2 + dp[pre - 1]);第iii个字符串是右括号,第i−1i-1i−1个字符串是左括号,然后和第i−2i-2i−2个字符结尾的合法串拼起来。dp[i] = max(.

2021-01-11 15:20:09 8

原创 LeetCode 407. 接雨水 II(优先队列+BFS,类Dijkstra)

给你一个 m x n 的矩阵,其中的值均为非负整数,代表二维高度图每个单元的高度,请计算图中形状最多能接多少体积的雨水。示例:给出如下 3x6 的高度图:[[1,4,3,1,3,2],[3,2,1,3,2,4],[2,3,3,2,3,1]]返回 4 。如上图所示,这是下雨前的高度图[[1,4,3,1,3,2],[3,2,1,3,2,4],[2,3,3,2,3,1]] 的状态。下雨后,雨水将会被存储在这些方块中。总的接雨水量是4。提示:1 <= m, n <= 110

2021-01-10 22:19:09 10

空空如也

tomjobs的留言板

发表于 2020-01-02 最后回复 2020-07-23

空空如也

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

TA关注的人 TA的粉丝

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