06 2018 档案

摘要:``` include using namespace std; const int MAXN=200005; int dp[MAXN],a[MAXN],n,ans= 100000; int main(){ scanf("%d",&n); for(int i=1;i 阅读全文
posted @ 2018-06-25 06:53 Roni_i 阅读(118) 评论(0) 推荐(0) 编辑
摘要:【链接】: "CF" 【代码】: include define PI acos( 1.0) define pb push_back define F first define S second define debug puts define setp cout n) { string s; cin 阅读全文
posted @ 2018-06-22 23:45 Roni_i 阅读(149) 评论(0) 推荐(0) 编辑
摘要:【链接】: "CF/4892" 【题意】: 一个人解决n个问题,这个问题的值比k小, 每次只能解决最左边的或者最右边的问题 解决了就消失了。问这个人能解决多少个问题。 【代码】: include define PI acos( 1.0) define pb push_back define F fi 阅读全文
posted @ 2018-06-22 23:06 Roni_i 阅读(185) 评论(0) 推荐(0) 编辑
摘要:【链接】: "CF" 【题意】:给你一个只含有括号的字符串,你可以将一种类型的左括号改成另外一种类型,右括号改成另外一种右括号 问你最少修改多少次,才能使得这个字符串匹配,输出次数 【分析】: 本题用到了栈。如果遇上左括号,就加进栈里。如果遇上右括号,就判断栈里的左括号是否和它匹配,不匹配就加一。不 阅读全文
posted @ 2018-06-22 22:32 Roni_i 阅读(337) 评论(0) 推荐(0) 编辑
摘要:问题描述 蒜头君在纸上写了一个串,只包含’(‘和’)’。一个’(‘能唯一匹配一个’)’,但是一个匹配的’(‘必须出现在’)’之前。请判断蒜头君写的字符串能否括号完全匹配,如果能,输出配对的括号的位置(匹配的括号不可以交叉,只能嵌套)。 输入格式 一行输入一个字符串只含有’(‘和’)’,输入的字符串长 阅读全文
posted @ 2018-06-22 22:25 Roni_i 阅读(425) 评论(0) 推荐(0) 编辑
摘要:1)凡出现左括弧,则进栈; 2)凡出现右括弧,首先检查栈是否空 若栈空,则表明该“右括弧”多余, 否则和栈顶元素比较, 若相匹配,则“左括弧出栈” , 否则表明不匹配。 3)表达式检验结束时, 若栈空,则表明表达式中匹配正确, 否则表明“左括弧”有余 有种匹配是: 添加了两个变量 left 和 ri 阅读全文
posted @ 2018-06-22 21:48 Roni_i 阅读(493) 评论(0) 推荐(0) 编辑
摘要:【链接】: "CF" 【题意】: 给你一个字符串只包含'(' 、‘ )’ 、‘ ?’三种字符,?你可以按需求转换成‘(’或’)‘ 定义一个区间为正确的括号序列,当且仅当对该区间进行如下操作之后,该序列为空: 每次删除序列中一对相邻的左右括号(),直到删到不能再删 Input 一个长度不超过5000的 阅读全文
posted @ 2018-06-22 21:43 Roni_i 阅读(190) 评论(0) 推荐(0) 编辑
摘要:【链接】: "CF" 【题意】: 给出n个字符串,保证只包含'('和')',求从中取2个字符串链接后形成正确的括号序列的方案数(每个串都可以重复使用)(像'()()'和'(())'这样的都是合法的,像')('和'('这样的是不合法的) 输入: 第一行一个整数n 第二行到第n+1行每行一个字符串 输出 阅读全文
posted @ 2018-06-22 21:17 Roni_i 阅读(167) 评论(0) 推荐(0) 编辑
摘要:【链接】: "CF" 【题意】:对任意一个数a[i] ,可以对任意 满足 i != j 且 a[i] a[j] && a[i] include include include include include include include include include include includ 阅读全文
posted @ 2018-06-22 18:34 Roni_i 阅读(218) 评论(0) 推荐(0) 编辑
摘要:【链接】: "CF" 【题意】:对于一个数n,每次加一的代价是a,每次减一的代价是b,求被m整除时的最小代价。 【分析】:分情况讨论,自己多举几个栗子。 【代码】: include include include include include include include include inc 阅读全文
posted @ 2018-06-22 13:00 Roni_i 阅读(178) 评论(0) 推荐(0) 编辑
摘要:变形课 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) Total Submission(s): 29518 Accepted Submission(s): 10683 Problem 阅读全文
posted @ 2018-06-19 21:53 Roni_i 阅读(284) 评论(0) 推荐(0) 编辑
摘要:诡异的楼梯 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) Total Submission(s): 17892 Accepted Submission(s): 4652 Proble 阅读全文
posted @ 2018-06-19 21:13 Roni_i 阅读(195) 评论(0) 推荐(0) 编辑
摘要:【前驱】: "在指定长度的棍子中找到能组成最大周长三角形的三根棍子" 链接:https://www.nowcoder.com/acm/contest/134/A 来源:牛客网 题目描述 铁子从森林里收集了n根木棍,她开始将它们按顺序的排成一排,从左到右依次为1到n,她回想起 在数学课上老师教她的三角 阅读全文
posted @ 2018-06-17 20:46 Roni_i 阅读(293) 评论(0) 推荐(0) 编辑
摘要:Dungeon Master Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 45743 Accepted: 17256 Description You are trapped in a 3D dungeon and need t 阅读全文
posted @ 2018-06-17 12:14 Roni_i 阅读(112) 评论(0) 推荐(0) 编辑
摘要:1 2 3 4 5 6 7 1 | | | | 2 | 3 | | 4 | | | | (Figure 1) = Wall | = No wall = No wall Figure 1 shows the map of a castle.Write a program that calculates 阅读全文
posted @ 2018-06-17 10:21 Roni_i 阅读(195) 评论(0) 推荐(0) 编辑
摘要:迷宫问题 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 31428 Accepted: 18000 Description 定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 阅读全文
posted @ 2018-06-16 23:53 Roni_i 阅读(285) 评论(0) 推荐(0) 编辑
摘要:棋盘问题 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 62164 Accepted: 29754 Description 在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋 阅读全文
posted @ 2018-06-16 23:17 Roni_i 阅读(240) 评论(0) 推荐(0) 编辑
摘要:Task schedule Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 515 Accepted: 309 Special Judge Description There are n preemptive jobs to be 阅读全文
posted @ 2018-06-14 09:29 Roni_i 阅读(308) 评论(0) 推荐(0) 编辑
摘要:自从Lele开发了Rating系统,他的Tetris事业更是如虎添翼,不久他遍把这个游戏推向了全球。 为了更好的符合那些爱好者的喜好,Lele又想了一个新点子:他将制作一个全球Tetris高手排行榜,定时更新,名堂要比福布斯富豪榜还响。关于如何排名,这个不用说都知道是根据Rating从高到低来排,如 阅读全文
posted @ 2018-06-14 08:49 Roni_i 阅读(204) 评论(0) 推荐(0) 编辑
摘要:include using namespace std; const int maxn = 1e5 + 10; const int mod = 142857; int t,n,m,k,x,u,v,num,ans; vector G[maxn]; int inDeg[maxn]; int sum[ma 阅读全文
posted @ 2018-06-13 22:04 Roni_i 阅读(169) 评论(0) 推荐(0) 编辑
摘要:确定比赛名次 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 33964 Accepted Submission(s): 13321 Probl 阅读全文
posted @ 2018-06-13 21:17 Roni_i 阅读(293) 评论(0) 推荐(0) 编辑
摘要:Legal or Not Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 10407 Accepted Submission(s): 4876 阅读全文
posted @ 2018-06-13 20:46 Roni_i 阅读(188) 评论(0) 推荐(0) 编辑
摘要:思路来自:与PKU3687一样 在基本的拓扑排序的基础上又增加了一个要求:编号最小的节点要尽量排在前面;在满足上一个条件的基础上,编号第二小的节点要尽量排在前面;在满足前两个条件的基础上,编号第三小的节点要尽量排在前面……依此类推。(注意,这和字典序是两回事,不可以混淆。) 如图 1 所示,满足要求 阅读全文
posted @ 2018-06-13 19:43 Roni_i 阅读(1230) 评论(0) 推荐(0) 编辑
摘要:逃生 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 6686 Accepted Submission(s): 1958 Problem Des 阅读全文
posted @ 2018-06-13 19:12 Roni_i 阅读(383) 评论(0) 推荐(0) 编辑
摘要:Genealogical tree Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7101 Accepted: 4585 Special Judge Description The system of Martians' blo 阅读全文
posted @ 2018-06-13 14:40 Roni_i 阅读(204) 评论(0) 推荐(0) 编辑
摘要:Sorting It All Out Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 38100 Accepted: 13453 Description An ascending sorted sequence of distin 阅读全文
posted @ 2018-06-13 13:26 Roni_i 阅读(248) 评论(0) 推荐(0) 编辑
摘要:"CF" A. Party time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard output A company has n employees numb 阅读全文
posted @ 2018-06-13 01:41 Roni_i 阅读(269) 评论(0) 推荐(0) 编辑
摘要:``` #include using namespace std; const int maxn = 1e5 + 10; const int mod = 142857; int t,n,m,k,x,u,v,w,num,flag; vector G[maxn]; int inDeg[maxn], ruDeg[maxn]; int virus[maxn]; queue q; bool topS... 阅读全文
posted @ 2018-06-13 00:52 Roni_i 阅读(212) 评论(0) 推荐(0) 编辑
摘要:"计蒜课" 【代码】: include using namespace std; const int maxn = 1e5 + 10; const int mod = 142857; int t,n,m,k,x,u,v,w,num; vector G[maxn]; int inDeg[maxn], 阅读全文
posted @ 2018-06-13 00:20 Roni_i 阅读(179) 评论(0) 推荐(0) 编辑
摘要:"hihocoder" 对于一个节点i来说,如果我们能够先计算出它所有前驱节点的病毒数量,就可以直接推算出它最后的病毒数量了,但是怎么来计算所有前驱节点呢? 这就要从图的性质入手了。我们现在的网络是没有环的,对于任意一个节点i,当它将自己所有的病毒都传送出去之后,它自身的病毒数量就不会改变了。那么我 阅读全文
posted @ 2018-06-13 00:02 Roni_i 阅读(185) 评论(0) 推荐(0) 编辑
摘要:"hihocoder 1174" [算法]: 1. 计算每一个点的入度值deg[i],这一步需要扫描所有点和边,复杂度O(N+M)。 2. 把入度为0的点加入队列Q中,当然有可能存在多个入度为0的点,同时它们之间也不会存在连接关系,所以按照任意顺序加入Q都是可以的。 3. 从Q中取出一个点p。对于每 阅读全文
posted @ 2018-06-11 16:16 Roni_i 阅读(223) 评论(0) 推荐(0) 编辑
摘要:【链接】: "A" 【题意】:给你n个数的序列和k。判断是否可以三个数组成k(同一个数可以拿多次) 【分析】:每个数vis记录一下。2层循环。两数之和不超过k以及剩下的数出现在序列中那么ok。 【代码】: include define ll long long define pb push_back 阅读全文
posted @ 2018-06-09 15:26 Roni_i 阅读(205) 评论(0) 推荐(0) 编辑
摘要:【链接】: "A" 【分析】:可以设置方向数组和标记数组。当不合法(越界/访问过)就转向,转向可以用now=(now+1)%4 【代码】: include define ll long long define pb push_back define inf 0x3f3f3f3f define pll 阅读全文
posted @ 2018-06-09 15:12 Roni_i 阅读(318) 评论(0) 推荐(0) 编辑
摘要:【链接】: "CF" 【题意】:n组样例,对于每组样例,给你三个数p q b,问你p/q在b进制下是不是一个有限小数,是的话输出Finite,否则输出Infinite。 【分析】:b的过程是对q约分,那么只要b包含q全部的因子即可。考虑1/q,一定是一个小于等于1的数,考虑将小数转化为b进制的过程, 阅读全文
posted @ 2018-06-09 12:13 Roni_i 阅读(180) 评论(0) 推荐(0) 编辑
摘要:循环小数与费马小定理 17/05/29 22:30:51 | Snakes 背景 题目出自之前亮灯问题、杨辉三角与Sierpinski三角形提及的生日题中的第三、四、五题。 题目 第三题 证明:对于任意非$2, 5$倍数正整数$n$且满足$n 1$,均存在正整数$k, i$满足$kn=10^i 1$ 阅读全文
posted @ 2018-06-09 01:26 Roni_i 阅读(894) 评论(0) 推荐(0) 编辑
摘要:【链接】: "CF982C" 【题意】:有一颗树,你需要切掉一些边,使这颗树分拆成若干个节点为偶数的联通分量,最多能切掉几条边。若不能切,输出 1。 【分析】: 1.若点数n为奇数,因为奇数不可能分为偶数,那么一定输出 1 2.若点数n为偶数,偶数=偶数+偶数。就从顶点1开始,当作父顶点开始dfs。 阅读全文
posted @ 2018-06-09 00:54 Roni_i 阅读(353) 评论(0) 推荐(0) 编辑
摘要:有一个棵树,树上有 n 个结点。结点的编号分别为 1…n,其中 1 是树的根结点。现在希望你帮忙计算每个结点作为根结点的子树分别有多少结点。 输入格式 第一行输入一个数字 n,代表树上结点的个数。(2≤n≤1000)接下来的 n−1 行,每行俩个数字 a,b,代表结点 a 到结点 b 有一条边。 输 阅读全文
posted @ 2018-06-09 00:17 Roni_i 阅读(624) 评论(0) 推荐(0) 编辑
摘要:【链接】: "CF" 【题意】:从一堆数中选一个最大子集,使得任意两个数相减的绝对值都是2的幂。 【分析】:首先很难的一点,需要想到子集最多只能有三个,四个及以上的子集一定不存在(可以证明)。当有三个元素时,则必有其中两对元素之差相等。 【代码】: include using namespace s 阅读全文
posted @ 2018-06-07 14:35 Roni_i 阅读(238) 评论(0) 推荐(0) 编辑
摘要:1.N皇后问题 2.油田问题 3.素数环问题 4.马踏棋盘问题 5.图的m着色问题 6.01背包问题 7.TSP问题 【Code 1:输出N皇后方案和个数】 include using namespace std; typedef long long ll; const int maxn = 105 阅读全文
posted @ 2018-06-05 11:09 Roni_i 阅读(169) 评论(0) 推荐(0) 编辑
摘要:【链接】: "CF" 【题意】:给定一棵树,要求拆成若干条简单路径,并且这些路径都经过一个公共节点。给出任意一个解决方案,如不存在输出No。 【分析】: 【代码】: include using namespace std; int n; int deg[100005]; // 每个点的度数 int 阅读全文
posted @ 2018-06-03 18:55 Roni_i 阅读(263) 评论(0) 推荐(0) 编辑
摘要:【链接】: "CF988C" 【题意】:在n个序列中任选两个序列,两个序列都除去他们中的一个数,使的总和相同 【分析】:map mp,从0~m遍历删除第i个数,mp[sum a[i]]={j+1,i+1}; 其中key是记录删掉某个数的剩下的数,value是一对以行列号用来确定位置以方便输出。若删掉 阅读全文
posted @ 2018-06-03 17:34 Roni_i 阅读(235) 评论(0) 推荐(0) 编辑
摘要:【链接】: "CF" 【分析】: 设上车前人数 x ,中途最大人数为 x+max ,最小人数为 x+min (max≥0,min≤0) 可得不等式组 x+max≤w, x+min≥0 整数解个数 为 max(0,w max+min+1) 求出 max,min 即可,有求和~记得long long 【 阅读全文
posted @ 2018-06-02 11:29 Roni_i 阅读(198) 评论(0) 推荐(0) 编辑
摘要:【链接】: " CF978C " 【分析】:在前缀和数组种二分找到 =询问数的位置,根据位置就好操作了 【代码】: include using namespace std; const int INF = 0x3f3f3f3f; define ll long long define ms(a,b) 阅读全文
posted @ 2018-06-02 00:43 Roni_i 阅读(289) 评论(0) 推荐(0) 编辑
摘要:"CF978B File Name" 【分析】:设置计数器cnt,计数x的个数;遇到非x,若cnt =3的话累加多出的个数,计数器清零;若最后cnt =3说明没遇到非x无法清零,那后部分就都是x,输出ans+=cnt 2 【代码】: include using namespace std; cons 阅读全文
posted @ 2018-06-01 23:35 Roni_i 阅读(299) 评论(0) 推荐(0) 编辑
摘要:【链接】: "CF978A" 【分析】:逆向思考+标记数组去重 【代码】: 阅读全文
posted @ 2018-06-01 23:05 Roni_i 阅读(192) 评论(0) 推荐(0) 编辑
摘要:【链接】: "CF987C" 【分析】:先求出每个s【i】后面比s【i】大的c【i】的最小值,然后枚举前两个数c(i),c(j)以及 j 后面 递增且存在最小值 的dp(j) 【代码】: include using namespace std; const int INF = 0x3f3f3f3f; 阅读全文
posted @ 2018-06-01 19:03 Roni_i 阅读(287) 评论(0) 推荐(0) 编辑
摘要:【链接】: "CF987A" 【分析】:运用map 【代码】: include include include include using namespace std; define N 100010 define M 2005 const int INF = 0x3f3f3f3f; define 阅读全文
posted @ 2018-06-01 11:48 Roni_i 阅读(159) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示