- 博客(105)
- 收藏
- 关注
原创 K-th Number POJ - 2104 (主席树+离散化)
You are working for Macrohard company in data structures department. After failing your previous task about key insertion you were asked to write a new data structure that would be able to return quic...
2019-07-20 10:37:10
307
原创 高斯消元模板
#include<bits/stdc++.h>#define ULL unsigned long long#define LL long long#define Max 100005#define mem(a,b) memset(a,b,sizeof(a));#define pb push_back#define mp make_pairusing namespace s...
2019-07-19 10:31:05
175
原创 Atcoder abc128 D
Problem StatementYour friend gave you a dequeue D as a birthday present.D is a horizontal cylinder that contains a row of N jewels.The values of the jewels are V1,V2,…,VNfrom left to right. There m...
2019-07-18 20:15:31
568
原创 atcoder abc128c
题意:有n个开关和m个灯泡,每个灯泡关联k个开关,当灯泡关联的开关开着的数量取余2等于p时,灯泡亮起,现在问你有多少种方式让灯泡全亮。思路:利用二进制,直接模拟所有状态即可。代码:#include<bits/stdc++.h>#define ULL unsigned long long#define LL long long#define Max 15#define me...
2019-07-18 16:43:34
477
原创 Subpalindromes URAL - 1989(树状数组+哈希)
You have a string and queries of two types:replace i’th character of the string by character a;check if substring sj…sk is a palindrome.InputThe first line contains a string consisting of n small ...
2019-07-17 19:46:35
280
原创 Poj2774 二分+哈希
题意:求两个字符串的最长连续公共子序列思路:开始直接暴力枚举每个长度,结果超时了。所以需要优化代码,第一个想法就是二分,既然要二分那就要证明这两个字符串公共子序列具有单调性,很显然它们是具有单调性的。代码:#include<stdio.h>#include<iostream>#include<string.h>#include<map>...
2019-07-17 09:03:06
280
原创 POJ 1200 Crazy Search(哈希)
题目描述给定一个字符串,其中含有不同的字母数量为m,现在求这个字符串中有多少个长度为n且长的互不相同的字符子串举个例子, n=3, m=4 ,字符串 “daababac”. 长度为3的不同的子串分别是: “daa”; “aab”; “aba”; “bab”; “bac”. 因此, 答案是5.Input第一行是两个整数n,m,,一个空格隔开。 接下来一行是我们要解决的字符串.( 你可以认为字...
2019-07-16 19:47:05
242
原创 Scu4438 栈+哈希
题目描述现在给定一个你很讨厌的字符串 A 和另外一个字符串 B,请删除在 B 中出现的所有 A。请注意:有可能在删除一个 A 后导致新的 A 出现,此时请继续删除,直到没有 A。输入格式输入为多组数据,请处理到 EOF。对于每组数据:第一行为你很讨厌的字符串 A,第二行为另外一个字符串 B,均仅包括小写字母。保证 A串 和 B串 的长度不超过 5000000 且 A、B 均不为空串。...
2019-07-16 15:55:27
1587
原创 POJ 2406 Power Strings
题目描述给定若干个长度 ≤ 1000000 的字符串,询问每个字符串最多是由多少个相同的子字符串重复连接而成的。如:ababab 则最多有 3 个 ab 连接而成。输入格式输入若干行,每行有一个字符串,字符串仅含英语字母。输入数据以"."结束。输出格式对于每组输入数据输出一行,找出每个字符串最多是由多少个相同的子字符串重复连接而成的。样例输入abcdaaaaababab.样...
2019-07-16 11:37:44
713
原创 Codeforces 154A
题目链接:154A题意:给你一个字符串,接下来给你n对字符,每对代表这两个字母有冲突不能相邻(一个字母只与不超过一个字母产生冲突),你可以删除某个字符来达到这个要求,现在问你最少需要删除多少个字符。思路:题目说了每个字母只与不超过一个字母产生冲突,所以可以知道n对字符串它们之间的解是独立的,接下来思考单独的一组,如果有连续的子字符串,全部由冲突字母构成,例如pg冲突,子字符串为pgppggg,...
2019-07-16 08:43:23
371
原创 Atcoder ABC132 D - Blue and Red Balls
D - Blue and Red BallsTime Limit: 2 sec / Memory Limit: 1024 MBScore : 400 pointsProblem StatementThere are K blue balls and N−K red balls. The balls of the same color cannot be distinguished. Snu...
2019-07-14 20:33:16
910
原创 组合数打表
根据组合数递推公式C(n,m)=C(m−1,n−1)+C(m,n−1);很容易得到以下代表的代码,m<=10000LL C[Max][Max];void Compare_C(){ C[0][0]=1; for(int i=1;i<Max;i++){ C[i][0]=C[i][i]=1; for(int j=1;j<=i;j++...
2019-07-14 20:20:25
301
原创 POJ2724 二分图最大匹配(最小边覆盖)
题目链接题意:有m台机器,每台机器有n个开关,开关有三种状态0,1,*,号表示可以是任意状态,即0,1都可以,你可以自己生成一些序列,当序列与机器开关所构成的序列一致时,你就可以关闭这台机器,每个序列里面仅包含一个号,现在问你,你手上最少需要多少个序列,才能关闭所有机器思路:首先要把二进制转换为十进制,然后将它们去重为什么要去重?很显然如果有n个序列一模一样和只有一个这样的序列,我都只要生成...
2019-06-03 20:16:26
346
原创 使用java实现记事本(超详细解释)
实验课老师要求写的,学习了网上n多大佬的博客后,自己写了一个简单的记事本程序效果图:实现代码:package test;import java.awt.*;import java.awt.event.*;import java.io.*;import javax.swing.*;public class Notepad extends JFrame implements Ac...
2019-05-30 20:05:53
10669
7
原创 POJ 1325 Machine Schedule (二分图最大匹配裸题)
题意:众所周知,机器调度是计算机科学中一个非常经典的问题,并且已经研究了很长的历史。调度问题在必须满足的约束的性质和期望的调度类型方面差别很大。这里我们考虑一个2机器调度问题。有两台机器A和B.机器A有n种工作模式,称为mode_0,mode_1,…,mode_n-1,同样机器B有m种工作模式,mode_0,mode_1,…, mode_m-1。一开始他们都在mode_0工作。对于给定的k个...
2019-05-27 23:42:14
414
原创 二分图最大匹配(模板)
//#include<bits/stdc++.h>#include<stdio.h>#include#include#include<string.h>#define LL long long#define Max 100005const LL mod=1e9+7;const LL LL_MAX=9223372036854775807;usin...
2019-05-27 19:49:29
399
原创 POJ 3041 Asteroids(最大流)
Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <= N <= 500). The grid contains K asteroids (1 <= K <= 10,000), which are conveni...
2019-05-24 01:07:17
303
原创 C - A Plug for UNIX POJ - 1087
题意:你作为某高管去住宿了,然后宾馆里有几种插座,分别有其对应型号,你携带了几种用电器(手机,电脑一类的),也有其对应型号;可是不一定用电器就能和插座匹配上,于是宾馆的商店里提供了一些转换器,这些转换器可以将某一型号电源转换成另一型号的。问,你的用电器最少会有多少种无法充电 摘自http://www.cnblogs.com/zznulw/p/5929247.html思路:很显然创建一个源点和一个...
2019-05-16 20:24:56
306
原创 Poj3436 网络流
ACM Computer FactoryTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 10431 Accepted: 3885 Special JudgeDescriptionAs you know, all the computers used for ACM contests must be identical...
2019-05-10 16:04:32
210
原创 网络流-dinic算法
//#include<bits/stdc++.h>#include<stdio.h>#include<string.h>#include<algorithm>#include<iostream>#include<queue>#define LL long long#define Max 100005const ...
2019-05-09 19:51:33
281
原创 网络流-EK算法
EK算法的思路:基于贪心的思想,每次选取一条起点到终点的路径,毋庸置疑,这条路的流量就等于这条路径上的权值是最小值。将这条路的权值都减去流量,再将路径的反向边加上流量(这样可以就给贪心一次反悔的机会),无限循环以上步骤,到找不到任何一条起点到终点的路,最后所有的最小值加起来就是最大流了。(这只是我对EK算法的总结,学习网络流还是去看别人的博客吧)代码:#include<stdio.h...
2019-05-09 19:21:38
474
原创 CSU 1778 多边形的公共部分(计算几何)
给定两个简单多边形,你的任务是判断二者是否有面积非空的公共部分。如下图中的两个矩形只有一条公共线段,没有公共面积。在本题中,简单多边形是指不自交(也不会接触自身)、不含重复顶点并且相邻边不共线的多 边形。注意:本题并不复杂,但有很多看上去正确的算法实际上暗藏缺陷,请仔细考虑各种情况。Input输入包含不超过 100 组数据。每组数据包含两行,每个多边形占一行。多边形的格式是:第一 个整数...
2019-05-06 10:24:34
644
原创 CF1017 C. The Phone Number
C. The Phone Numbertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMrs. Smith is trying to contact her husband, John Smith, but she forgot the...
2019-05-05 11:23:00
335
原创 CF 1082C. Multi-Subject Competition
C. Multi-Subject Competitiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA multi-subject competition is coming! The competition has m diff...
2019-04-29 19:44:16
250
原创 CF1070H. BerOS File Suggestion
H. BerOS File Suggestiontime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp is working on a new operating system called BerOS. He asks y...
2019-04-26 11:00:02
357
原创 CF 1060C. Maximum Subrectangle
C. Maximum Subrectangletime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given two arrays a and b of positive integers, with length n a...
2019-04-25 21:13:53
344
原创 CF1102D Balanced Ternary String(构造)
D. Balanced Ternary Stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s consisting of exactly n characters, and ea...
2019-04-23 15:18:51
404
原创 CF901 A. Hashing Trees(构造)
A. Hashing Treestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSasha is taking part in a programming competition. In one of the problems she...
2019-04-22 15:21:02
385
原创 CF908 C. New Year and Curling
C. New Year and Curlingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputCarol is currently curling.She has n disks each with radius r on the ...
2019-04-22 10:50:22
290
原创 CF920C C. Swap Adjacent Element
C. Swap Adjacent Elementstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an array a consisting of n integers. Each integer from 1 to ...
2019-04-21 20:32:44
448
原创 Codeforces 940 C. Phone Numbers
C. Phone Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnd where the are the phone numbers?You are given a string s consisting of l...
2019-04-19 15:13:56
390
原创 I - Minimize the error CodeForces - 960B (贪心)
B. Minimize the errortime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two arrays A and B, each of size n. The error, E, between t...
2019-04-18 10:35:16
228
原创 G - Cyclic Components CodeForces - 977E (dfs or 并查集)
E. Cyclic Componentstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an undirected graph consisting of n vertices and m edges. Y...
2019-04-17 10:08:50
312
原创 D - Liebig's Barrels CodeForces - 985C
C. Liebig’s Barrelstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have m = n·k wooden staves. The i-th stave has length ai. You have to ...
2019-04-16 11:29:58
482
原创 C - Bracket Sequences Concatenation Problem CodeForces - 990C
C. Bracket Sequences Concatenation Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA bracket sequence is a string containing only char...
2019-04-16 09:16:16
238
原创 G - Game HDU - 5242 (dfs)
It is well known that Keima Katsuragi is The Capturing God because of his exceptional skills and experience in ‘‘capturing’’ virtual girls in gal games. He is able to play k games simultaneously.One ...
2019-04-15 10:49:07
253
原创 H - Minimum Ternary String CodeForces - 1009B (思维)
You are given a ternary string (it is a string which consists only of characters ‘0’, ‘1’ and ‘2’).You can swap any two adjacent (consecutive) characters ‘0’ and ‘1’ (i.e. replace “01” with “10” or v...
2019-04-13 20:20:31
203
原创 J - Convert to Ones CodeForces - 997A (思维)
You’ve got a string a1,a2,…,an, consisting of zeros and ones.Let’s call a sequence of consecutive elements ai,ai + 1,…, aj (1≤ i≤ j≤ n) a substring of string a.You can apply the following operations...
2019-04-12 10:49:14
399
原创 E - Curiosity Has No Limits CodeForces - 1031B(暴力)
B. Curiosity Has No Limitstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhen Masha came to math classes today, she saw two integer sequences...
2019-04-11 20:15:50
276
原创 C. Coffee Break CodeForces - 1041C (贪心)
Recently Monocarp got a job. His working day lasts exactly m minutes. During work, Monocarp wants to drink coffee at certain moments: there are n minutes a1,a2,…,an, when he is able and willing to tak...
2019-04-11 17:29:06
472
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅