- 博客(28)
- 收藏
- 关注
原创 Leetcode 78. 子集
个人感觉和leetcode上的39、40整体思路是差不多的,只要那几道组合过了这个也不难,index变量的存在保证了只向后查找或添加元素,避免重复菜鸡做法:class Solution { public List<List<Integer>> subsets(int[] nums) { List<List<Integer>> ans = new ArrayList<>(); solution(-1,
2020-09-20 10:34:46
113
原创 Leetcode 面试题 10.02. 变位词组
先对每个字符串排序,随后用Map<String,List<String>>存储<排序后字符串,字符串链表>public class Leetcode10_02 { public List<List<String>> groupAnagrams(String[] strs) { String[] string = new String[strs.length]; HashMap<Strin...
2020-09-14 22:03:23
148
原创 Leetcode-01 两数之和
哈希表解决:先把所有值存入哈希表,随后一个循环解决public class Leetcode1 { public int[] twoSum(int[] nums, int target) { HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(); int[] ans = new int[2]; for (int i = 0;i < nums
2020-09-14 20:07:06
129
原创 Codeforces Round #527 (Div. 3) C
C. Prefixes and SuffixesIvan wants to play a game with you. He picked some string ss of length nn consisting only of low...
2018-12-20 10:05:29
417
1
原创 Codeforces Round #527 (Div. 3) B
B. Teams FormingThere are nn students in a university. The number of students is even. The ii-th student has programmin...
2018-12-19 21:11:44
156
原创 Codeforces Round #527 (Div. 3) A
A. Uniform StringYou are given two integers nn and kk.Your task is to construct such a string ss of length nn that...
2018-12-19 20:58:04
167
原创 Codeforces Round #526 (Div. 2) B
B. Kvass and the Fair NutThe Fair Nut likes kvass very much. On his birthday parents presented him nn kegs of kvass. The...
2018-12-11 09:57:34
298
原创 Codeforces Round #526 (Div. 2) A
A. The Fair Nut and ElevatorThe Fair Nut lives in nn story house. aiai people live on the ii-th floor of the house. Every person uses...
2018-12-11 08:50:02
404
原创 Codeforces Round #525 (Div. 2) C
C. Ehab and a 2-operation taskYou're given an array aa of length nn. You can perform the following operations on it:c...
2018-12-07 17:02:15
124
原创 Codeforces Round #525 (Div. 2) B
B. Ehab and subtraction You're given an array aa. You should repeat the following operation kk times: find the minimum no...
2018-12-06 15:53:19
228
1
原创 hdu 2489
Minimal Ratio Tree Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
2018-12-01 10:44:18
241
2
原创 Codeforces Round #524 (Div. 2)B
题意:就是一个简单的序列,奇数位为负,偶数位为正,求[l, r]的区间和 #include<iostream>#include<cstdio>using namespace std;int main(){ int q; scanf("%d", &q); while(q --) { int l, r; scanf("%d%...
2018-11-30 22:39:10
104
原创 Codeforces Round #524 A
A. Petya and Origamistandard outputPetya is having a party soon, and he has decided to invite his nn friends.He wants...
2018-11-28 13:51:22
166
原创 四边形不等式算法证明
ps:本人小白,文章可能存在错误,希望大佬谅解或指出错误先来看一道常规的区间dp,在这里以石子合并为例题题目描述:有N堆石子排成一排,每堆石子有一定的数量。现要将N堆石子并成为一堆。合并的过程只能每次将相邻的两堆石子堆成一堆,每次合并花费的代价为这两堆石子的和,经过N-1次合并后成为一堆。求出总的代价最小值。输入有多组测试数据,输入到文件结束。每组测试数据第一行有一个整数n,...
2018-10-12 13:51:08
4838
5
原创 东秦oj 1751
题目链接1751: 棋盘问题题目描述:给定一个M×N的棋盘,只能向下或者向右走,其中有一些点不能通过,问从左上角((0,0)点)到右下角((M-1,N-1)点)有多少种路径? 输入:第一行两个数,M和N,表示M行N列。(0<M<=30,0<=N<=30)接下来一个数T,表示有T个障碍点。接下来T行,每行两个数X,Y,表示(X,Y)点有障碍。(...
2018-09-03 21:49:26
393
1
原创 Tomcat下载从零创建"Hollow word"
Tomcat从零创建"Hollow word"ps - 这篇文章的是给像我一样的小白看方便学习的,欢迎大佬指出错误对于刚刚接触这一方面的小白肯定很懵的,一会要下载这个一会要配置那个,所以我就从下载到建立第一个web项目梳理一下。第一步 ...
2018-08-21 21:18:12
578
原创 hdu 1281
棋盘游戏 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submissi...
2018-08-15 21:10:46
208
原创 hdu 1151
Air RaidTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6389 Accepted Submission(s): 4230 Problem DescriptionConsider a town where...
2018-08-15 17:13:43
217
原创 hdu 1150
Problem DescriptionAs we all know, machine scheduling is a very classical problem in computer science and has been studied for a very long history. Scheduling problems differ widely in the nature...
2018-08-15 16:23:00
222
原创 hdu 1068
自己写的板子就是好用,这道题是求的最大独立集不是最大匹配(英语弱渣),没看懂题调了半天代码找不到错。。GG最大独立集 = n - (最大匹配 / 2)#include<iostream>#include<vector>#include<memory.h>#include<algorithm>using namespace std;...
2018-08-15 15:39:06
237
原创 二分匹配匈牙利算法
struct Hungary { int n, m; // 两个集合点的个数 int vis[maxn], link[maxn]; vector <int> edge[maxn]; void init(int n, int m) { this -> n = n; this -> m = m; memset(link, -1, sizeof...
2018-08-15 15:35:11
148
原创 Floyd
struct Floyd { int n, m; int edge[maxn][maxn]; void init(int n) { this -> n = n; for(int i = 0;i <= n;i ++) for(int j = 0;j <= n;j ++) edge[i][j] = INF; } void addEdge(int s...
2018-08-15 10:09:41
851
原创 Dijkstra-优先队列
struct Edge { int from, to, dist; Edge (int _from, int _to, int _dist):from(_from), to(_to), dist(_dist){}};struct Dijkstra { struct node{ int d, u; node (int _d, int _u):d(_d), u(_u){} ...
2018-08-14 22:15:45
1677
原创 最大流 结构体
最大流EdmondsKarp 算法模板struct edge { int from, to, cap, flow; edge (int _from, int _to, int _cap, int _flow):from(_from), to(_to), cap(_cap), flow(_flow){}};struct EdmondsKarp { int n, m; vector ...
2018-08-14 20:15:35
104
原创 Bellman-Ford 结构体
Bellman-Ford 朴素做法struct edge { int from, to, cap, flow; edge (int _from, int _to, int _cap, int _flow):from(_from), to(_to), cap(_cap), flow(_flow){}};struct EdmondsKarp { int n, m; vector &l...
2018-08-14 20:13:09
105
原创 dijkstra 结构体
dijkstra--O(n^2)做法模板struct Dijkstra { int n; int mp[maxn][maxn]; // 记录地图 int dis[maxn], vis[maxn]; void init(int n) // 初始化 { this -> n = n; memset(mp, INF, sizeof(mp)); }...
2018-08-14 18:46:46
224
2
原创 HDU Flow Problem
Problem DescriptionNetwork flow is a well-known difficult problem for ACMers. Given a graph, your task is to find out the maximum flow for the weighted directed graph. InputThe first line o...
2018-08-13 17:29:30
348
原创 头铁的地鼠
东秦 - 头铁的地鼠题目描述:你是一只地鼠,最喜欢在人类所谓的打地鼠游戏中戏弄愚蠢的人类。你纵横天下数十年,仍无人能打爆你的头,因而被称为当代的头铁王。秉承着敌进我退、敌退我扰的策略,你总结出自己的一套作死策略:偶冒奇不冒,即你只会从一个已经被敲打过偶数次的地洞的冒头。打地鼠游戏:N个线性排列的地洞,人类手持铁锤,每一次造成L到R洞口的范围攻击。你只允许在愚蠢的人类攻击的同时冒头,...
2018-08-07 18:48:26
520
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人