Acm
文章平均质量分 67
Gee_Zer
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
CF620 E. New Year Tree(DFS序+状态压缩+线段树)
题目链接:CF620E题意: 给你一颗n个节点的树,每个节点被染上了颜色,然后就是m次查询。 查询的方式有两种 1,将以z为根的子树的结点全部更新为颜色X 2,问以z为根的子树的结点的不同颜色数量。默认根为1Input第一行输入n,m(4*10^5) 第二行 输入每个节点的颜色(n个) 颜色X<=60 接下来n-1行就是两个点相连 最后m行查询 其中 1 z X 代表操作1, 2 x ...原创 2019-07-27 16:46:42 · 306 阅读 · 0 评论 -
Scu4438 栈+哈希
题目描述现在给定一个你很讨厌的字符串 A 和另外一个字符串 B,请删除在 B 中出现的所有 A。请注意:有可能在删除一个 A 后导致新的 A 出现,此时请继续删除,直到没有 A。输入格式输入为多组数据,请处理到 EOF。对于每组数据:第一行为你很讨厌的字符串 A,第二行为另外一个字符串 B,均仅包括小写字母。保证 A串 和 B串 的长度不超过 5000000 且 A、B 均不为空串。...原创 2019-07-16 15:55:27 · 1582 阅读 · 0 评论 -
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 · 552 阅读 · 0 评论 -
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 · 471 阅读 · 0 评论 -
POJ 2406 Power Strings
题目描述给定若干个长度 ≤ 1000000 的字符串,询问每个字符串最多是由多少个相同的子字符串重复连接而成的。如:ababab 则最多有 3 个 ab 连接而成。输入格式输入若干行,每行有一个字符串,字符串仅含英语字母。输入数据以"."结束。输出格式对于每组输入数据输出一行,找出每个字符串最多是由多少个相同的子字符串重复连接而成的。样例输入abcdaaaaababab.样...原创 2019-07-16 11:37:44 · 708 阅读 · 0 评论 -
Codeforces 154A
题目链接:154A题意:给你一个字符串,接下来给你n对字符,每对代表这两个字母有冲突不能相邻(一个字母只与不超过一个字母产生冲突),你可以删除某个字符来达到这个要求,现在问你最少需要删除多少个字符。思路:题目说了每个字母只与不超过一个字母产生冲突,所以可以知道n对字符串它们之间的解是独立的,接下来思考单独的一组,如果有连续的子字符串,全部由冲突字母构成,例如pg冲突,子字符串为pgppggg,...原创 2019-07-16 08:43:23 · 366 阅读 · 0 评论 -
P3370 【模板】字符串哈希
题目描述如题,给定N个字符串(第i个字符串长度为Mi,字符串内包含数字、大小写字母,大小写敏感),请求出N个字符串中共有多少个不同的字符串。友情提醒:如果真的想好好练习哈希的话,请自觉,否则请右转PJ试炼场:)输入输出格式输入格式:第一行包含一个整数N,为字符串的个数。接下来N行每行包含一个字符串,为所提供的字符串。输出格式:输出包含一行,包含一个整数,为不同的字符串个数。输入输...原创 2019-12-23 08:40:02 · 301 阅读 · 0 评论 -
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 · 906 阅读 · 0 评论 -
POJ2724 二分图最大匹配(最小边覆盖)
题目链接题意:有m台机器,每台机器有n个开关,开关有三种状态0,1,*,号表示可以是任意状态,即0,1都可以,你可以自己生成一些序列,当序列与机器开关所构成的序列一致时,你就可以关闭这台机器,每个序列里面仅包含一个号,现在问你,你手上最少需要多少个序列,才能关闭所有机器思路:首先要把二进制转换为十进制,然后将它们去重为什么要去重?很显然如果有n个序列一模一样和只有一个这样的序列,我都只要生成...原创 2019-06-03 20:16:26 · 343 阅读 · 0 评论 -
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 · 298 阅读 · 0 评论 -
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 · 411 阅读 · 0 评论 -
二分图最大匹配(模板)
//#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 · 394 阅读 · 0 评论 -
C - A Plug for UNIX POJ - 1087
题意:你作为某高管去住宿了,然后宾馆里有几种插座,分别有其对应型号,你携带了几种用电器(手机,电脑一类的),也有其对应型号;可是不一定用电器就能和插座匹配上,于是宾馆的商店里提供了一些转换器,这些转换器可以将某一型号电源转换成另一型号的。问,你的用电器最少会有多少种无法充电 摘自http://www.cnblogs.com/zznulw/p/5929247.html思路:很显然创建一个源点和一个...原创 2019-05-16 20:24:56 · 299 阅读 · 0 评论 -
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 · 236 阅读 · 0 评论 -
CF600E Tree Requests(树上启发式合并模板题)
题目链接:CF600EYou are given a rooted tree with root in vertex 1. Each vertex is coloured in some colour.Let’s call colour c dominating in the subtree of vertex v if there are no other colours that appe...原创 2019-07-23 20:26:26 · 500 阅读 · 0 评论 -
poj3468 A Simple Problem with Integers(线段树区间更新+区间求和 数组模板)
Language:A Simple Problem with IntegersTime Limit: 5000MS Memory Limit: 131072KTotal Submissions: 162897 Accepted: 50267Case Time Limit: 2000MSDescriptionYou have N integers, A1, A2, … , AN. Y...原创 2019-07-26 10:21:03 · 204 阅读 · 0 评论 -
922 D. Robot Vacuum Cleaner
题目链接:922DD. Robot Vacuum Cleanertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPushok the dog has been chasing Imp for a few hours already....原创 2019-07-22 10:54:56 · 401 阅读 · 0 评论 -
HDU - 3887 Counting Offspring(dfs序+主席树)
Problem DescriptionYou are given a tree, it’s root is p, and the node is numbered from 1 to n. Now define f(i) as the number of nodes whose number is less than i in all the succeeding nodes of node i...原创 2019-07-25 17:03:22 · 187 阅读 · 0 评论 -
abc134 D - Preparing Boxes
题目链接:ABC 134D题意:给你一个序列a,让你构造一个序列b,序列里面只有数字0和1,满足以下条件:对于位置i,将所有是i的倍数的下标里的值相加,取余2必须等于ai。思路:直接从后往前模拟一遍就可以了,因为后面的数会影响前面的数,所以必须先确定后面的数。那么怎么确定i位置的值是什么呢,只有将它的倍数的值全部加起来(除了一倍),如果取余和ai相等那么bi就是0,否则的话改为1。代码:...原创 2019-07-21 16:04:59 · 573 阅读 · 0 评论 -
abc134 E
题目链接:abc134 E题意:给你n个数,现在要将它们染色,两个数字有一样的颜色必需满足以下条件,当i<j,Ai<Aj。意思就是如果它们颜色要相同就必须要是一个上升子序列。思路:直接模拟就可以了。假定一个集合,一个数加入集合,只有两种情况,如果集合中有比它小的数字,那么它们可以有一个颜色,将这个数替换比他小的那个数(保证子序列它们是递增的),第二种情况就是,没有比他小的了,那么...原创 2019-07-21 15:27:16 · 447 阅读 · 0 评论 -
CF208 E.Blood Cousins(树上启发式合并)
题目链接:CF208EPolycarpus got hold of a family relationship tree. The tree describes family relationships of n people, numbered 1 through n. Each person in the tree has no more than one parent.Let’s cal...原创 2019-07-24 20:08:18 · 542 阅读 · 0 评论 -
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 · 272 阅读 · 0 评论 -
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 · 300 阅读 · 0 评论 -
Poj2774 二分+哈希
题意:求两个字符串的最长连续公共子序列思路:开始直接暴力枚举每个长度,结果超时了。所以需要优化代码,第一个想法就是二分,既然要二分那就要证明这两个字符串公共子序列具有单调性,很显然它们是具有单调性的。代码:#include<stdio.h>#include<iostream>#include<string.h>#include<map>...原创 2019-07-17 09:03:06 · 278 阅读 · 0 评论 -
CodeForces - 208E Blood Cousins(树上启发式合并)
Polycarpus got hold of a family tree. The found tree describes the family relations of n people, numbered from 1 to n. Every person in this tree has at most one direct ancestor. Also, each person in t...原创 2019-07-24 10:36:55 · 363 阅读 · 0 评论 -
D. Tree Requests (树上启发式合并)
题目链接:CF570DRoman planted a tree consisting of n vertices. Each vertex contains a lowercase English letter. Vertex 1 is the root of the tree, each of the n - 1 remaining vertices has a parent in the t...原创 2019-07-24 09:16:44 · 736 阅读 · 0 评论 -
高斯消元模板
#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 · 169 阅读 · 0 评论 -
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 · 208 阅读 · 0 评论 -
网络流-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 · 277 阅读 · 0 评论 -
树状数组入门(求逆序对,区间更新+区间查询,单点更新+区间查询)
敌兵布阵 HDU - 1166 (单点更新+区间查询)#include<bits/stdc++.h>#define LL long long#define Max 100005#define Mod 1e9+7const LL mod=1e9+7;const LL inf=0x3f3f3f3f;using namespace std;int c[50005],n,x;...原创 2019-04-02 11:01:07 · 278 阅读 · 0 评论 -
D. Lunar New Year and a Wander CodeForces - 1106D(类prim+类bfs)
Lunar New Year is approaching, and Bob decides to take a wander in a nearby park.The park can be represented as a connected graph with n nodes and m bidirectional edges. Initially Bob is at the node ...原创 2019-04-10 20:41:26 · 435 阅读 · 0 评论 -
入门OJ 3793: [Noip模拟题]剪草(贪心+DP)
题目链接:入门OJ3793Description有N棵小草,编号0至N-1。奶牛Bessie不喜欢小草,所以Bessie要用剪刀剪草,目标是使得这N棵小草的高度总和不超过H。在第0时刻,第i棵小草的高度是h[i],接下来的每个整数时刻,会依次发生如下三个步骤:(1)每棵小草都长高了,第i棵小草长高的高度是grow[i]。(2)Bessie选择其中一棵小草并把它剪平,这棵小草高度变为0。...原创 2019-03-20 10:29:48 · 417 阅读 · 0 评论 -
Codeforces Round #533 (Div. 2) D. Kilani and the Game
题意:给你n,m,p分别代表矩阵的为n*m,p个起点,每个起点的向四周扩散的速度为si问最后每个起点可以占领多少个格子。思路:很显然这是一个类bfs,但是有多个起点,而且规定了一次每个点只能走si步,所以可以考虑用两个队列,一个走到了哪里,一个用来bfs,在加上循环控制步数,详细请看代码。#include<bits/stdc++.h>#define LL long long#...原创 2019-01-21 23:05:20 · 293 阅读 · 0 评论 -
Atcoder Beginner Contest 115 D
D - ChristmasTime Limit: 2 sec / Memory Limit: 1024 MBScore :400400 pointsProblem StatementIn some other world, today is Christmas.Mr. Takaha decides to make a multi-dimensional burger in his p...原创 2018-12-19 17:09:56 · 295 阅读 · 1 评论 -
Delivery Man(贪心)
一开始以为可以用优先队列写,每次选择小费最多的,结果WA,正确的贪心思想是按照两个数的差排序,然后每次选择小费最多的即可。代码如下:#include<bits/stdc++.h>#define LL long long#define Max 100005#define Mod 1e9+7const LL mod=1e9+7;const LL inf=0x3f3f3f3f...原创 2018-11-26 12:51:39 · 508 阅读 · 0 评论 -
Rails(Stack)
There is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds were extremely limited that time. It was possible to ...原创 2018-07-26 11:04:45 · 275 阅读 · 0 评论 -
USACO ORZ(dfs+set)
题目: Like everyone, cows enjoy variety. Their current fancy is new shapes for pastures. The old rectangular shapes are out of favor; new geometries are the favorite. I. M. Hei, the lead cow pasture ...原创 2018-07-26 10:54:08 · 480 阅读 · 0 评论 -
排列2
题目: Ray又对数字的列产生了兴趣: 现有四张卡片,用这四张卡片能排列出很多不同的4位数,要求按从小到大的顺序输出这些4位数。 Input 每组数据占一行,代表四张卡片上的数字(0<=数字<=9),如果四张卡片都是0,则输入结束。 Output 对每组卡片按从小到大的顺序输出所有能由这四张卡片组成的4位数,千位数字相同的在同一行,同一行中每个四位数间用空格分隔。 ...原创 2018-07-26 10:44:05 · 1143 阅读 · 0 评论 -
Ignatius and the Princess II
题目: Now our hero finds the door to the BEelzebub feng5166. He opens the door and finds feng5166 is about to kill our pretty Princess. But now the BEelzebub has to beat our hero first. feng5166 says, ...原创 2018-07-26 10:34:59 · 182 阅读 · 0 评论 -
士兵队列训练问题
题目: 某部队进行新兵队列训练,将新兵从一开始按顺序依次编号,并排成一行横队,训练的规则如下:从头开始一至二报数,凡报到二的出列,剩下的向小序号方向靠拢,再从头开始进行一至三报数,凡报到三的出列,剩下的向小序号方向靠拢,继续从头开始进行一至二报数。。。,以后从头开始轮流进行一至二报数、一至三报数直到剩下的人数不超过三人为止。 Input 本题有多个测试数据组,第一行为组数N,接着为N行新兵...原创 2018-07-26 10:29:05 · 306 阅读 · 0 评论
分享