Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them: One day, Yuta got a string which contains n letters but Rikka lost it in accident. Now…
http://219.244.176.199/JudgeOnline/problem.php?id=1215 这是这次微软和百度实习面试的一道题,题目大意就是:有一个n*m的矩阵,已知它每一行都是不严格递增的,而且每一列都是不严格递增.给你一个数k,请你判断k是否存在于矩阵中. 微软面试的时候没有想到很好的做法,后来想了好久,发现就是一个在矩形上的二分.对于一个矩形,我选取中间一列mid列二分,那么能得到一个index,如果a[index][mid]不为k,那么index以上的都小于k,inde…
Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them: For a tree T, let F(T,i) be the distance between vertice 1 and vertice i.(The length of…
Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them: Yuta has a non-direct graph with n vertices and m edges. The length of each edge is 1.…
Description Ray又对数字的列产生了兴趣: 现有四张卡片,用这四张卡片能排列出很多不同的4位数,要求按从小到大的顺序输出这些4位数.   Input 每组数据占一行,代表四张卡片上的数字(0<=数字<=9),如果四张卡片都是0,则输入结束.   Output 对每组卡片按从小到大的顺序输出所有能由这四张卡片组成的4位数,千位数字相同的在同一行,同一行中每个四位数间用空格分隔. 每组输出数据间空一行,最后一组数据后面没有空行.   Sample Input 1 2 3 4 1 1 2…
[HDU5421]Victor and String(回文树) 题面 Vjudge 大意: 你需要支持以下操作: 动态在前端插入一个字符 动态在后端插入一个字符 回答当前本质不同的回文串个数 回答当前回文串个数 题解 回文树前端插入的操作,学一学感觉并不难? 额外维护一下一个前端插入的\(last\) 然后就和后端插入一模一样,前端插入时就是前端插入的\(last\) 唯一会产生的影响的就是当前字符差完后, 发现现在的\(last\)就是整个串,那么就要更新另外一端的\(last\)为当前这一端…
这题建立一棵回文树,然后用dfs搜索答案,但是有一点需要注意,就是打vis的标记时,如果标记为1,那么在好几个节点都对同一个字符i打过标记,此时的搜索从字符i点回溯,回到它的父亲节点,搜索其它的字符,回溯的时候把vis[i]标记成0了,之前的vis[i]标记全被清空了,如果该父亲的其它字符节点下,有字符i的孩子,则此时统计就会出错.所以打vis标记的时候让vis++,而不是标记为0. #include <iostream> #include <stdio.h> using name…
Victor and String Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/262144 K (Java/Others) Total Submission(s): 163    Accepted Submission(s): 78 Problem Description Victor loves to play with string. He thinks a string is charming as the…
题目链接 题意:给定一个字符串\(|S|\le 3\times 10^5\) 对于每个 \(i\in [1,|S|]\) 求有多少子串\(s_ls_{l+1}\cdots s_r\)满足下面条件 \(r-l+1 = i\) \(s_ls_{l+1}\cdots s_r\)是一个回文串 \(s_ls_{l+1}\cdots s_{\lfloor(l+r)/2\rfloor}\)也是一个回文串 回文树学习:https://blog.csdn.net/Clove_unique/article/deta…
Problem Description You are given a string S=s1s2..s|S| containing only lowercase English letters. For each integer i∈[1,|S|] , please output how many substrings slsl+1...sr satisfy the following conditions: ∙ r−l+1 equals to i. ∙ The substring slsl+…