http://codeforces.com/contest/508/problem/D 以上是题目链接 题目大意 给n个字符串看能不能链接在一起 因为 三个三个分割 所以字符串 如abc ab作为起点 bc作为终点 hash思想 加细节处理 欧拉图均满足 #include<cstdio> #include<map> //#include<bits/stdc++.h> #include<vector> #include<stack> #includ…
题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, 然后接下来的t秒需要的蜡烛都燃烧着,超过t秒,每减少一秒灭一支蜡烛,好!!! 详细解释:http://blog.csdn.net/kalilili/article/details/43412385 */ #include <cstdio> #include <algorithm> #i…
题目传送门 /* 题意:从前面找一个数字和末尾数字调换使得变成偶数且为最大 贪心:考虑两种情况:1. 有偶数且比末尾数字大(flag标记):2. 有偶数但都比末尾数字小(x位置标记) 仿照别人写的,再看自己的代码发现有清晰的思维是多重要 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <cstring> #include…
D. Tanya and Password Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/508/problem/D Description While dad was at work, a little girl Tanya decided to play with dad's password to his secret database. Dad's password is a stri…
题目链接:http://codeforces.com/contest/508/problem/E 输入一个n,表示有这么多对括号,然后有n行,每行输入一个区间,第i行的区间表示从前往后第i对括号的左括号跟右括号之间的距离在这个区间的范围内,问是否存在这样的括号序列. 我的做法是比较繁琐,稍微看了下别人的代码,比我的短,应该有更简单 的做法.我的做法是从后往前构造括号序列,每次添加一对括号之前,先把当前的括号序列扫一遍,例如这个括号序列:(())()((()))   ,很显然,现在我要新增一对括号…
A. Pasha and Pixels     题意就是给一个n*m的矩阵,k次操作,一开始矩阵全白,一次操作可以染黑一个格子,问第几次操作可以使得矩阵中存在一个2*2的黑色矩阵.直接模拟即可 代码: #include<cstdio> #include<algorithm> #include<map> #include<cstring> #include<vector> #include<cmath> #include<stri…
题目传送门 /* 模拟水题:给定n*m的空白方格,k次涂色,将(x,y)处的涂成黑色,判断第几次能形成2*2的黑色方格,若不能,输出0 很挫的判断四个方向是否OK */ #include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <cstring> #include <map> using namespace std; ; c…
C. Anya and Ghosts time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lo…
E. Arthur and Brackets time limit per test 2 seconds memory limit per test 128 megabytes input standard input output standard output Notice that the memory limit is non-standard. Recently Arthur and Sasha have studied correct bracket sequences. Arthu…
C. Anya and Ghosts time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Anya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight. Anya has lo…