D. Restoration of string time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A substring of some string is called the most frequent, if the number of its occurrences is not less than number of…
[Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file for some programming competition problem. His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually ge…
[题目]B. Restoration of string [题意]当一个字符串在字符串S中的出现次数不小于任意子串的出现次数时,定义这个字符串是高频字符串.给定n个字符串,求构造出最短的字符串S满足着n个字符串都是高频字符串,若不存在输出NO,若存在多个输出字典序最小的一个.n<=10^5,Σ|si|<=10^5. [算法]模拟(图论?字符串?) [题解]首先出现频率都是1次,多次没有意义,所以每个字母至多出现一次. 那么对于出现在n个字符串中的子串ab,要求在S中ab也必须相邻. 所以对n个…
ACM ICPC 每个队伍必须是3个人 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<vector> #include<algorithm> using namespace std; int cmp(const void * x, const void * y) { //x < y : -; } ]; int main() { #ifndef ONLINE_…
[链接] 我是链接,点我呀:) [题意] 给你n个字符串. 让你构造一个字符串s. 使得这n个字符串. 每个字符串都是s的子串. 且都是出现次数最多的子串. 要求s的长度最短,且s的字典序最小. [题解] 如果s是出现最多的子串. 那么s的任意一个子串也都是出现次数最多的子串. 那么考虑"ab"这样一个子串. 则肯定要有字符'a'后面接的一定是'b' 且字符'b'前接的一定是'a' 不然'a'或'b'的出现次数一定会大于"ab"了. 则对于任意一个字符串s,在s[i…
题目链接:http://codeforces.com/problemset/problem/632/C C. The Smallest String Concatenation time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You're given a list of n strings a1, a2, ..., an. Y…
You're given a list of n strings a1, a2, ..., an. You'd like to concatenate them together in some order such that the resulting string would be lexicographically smallest. Given the list of strings, output the lexicographically smallest concatenation…
A:每次看是否有能走回去的房间,显然最多只会存在一个,如果有走过去即可,否则开辟新房间并记录访问时间. #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; #define ll long long #define N 200010…
D. String Game time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty…
题目链接: http://codeforces.com/problemset/problem/710/E E. Generate a String time limit per test 2 secondsmemory limit per test 512 megabytes 问题描述 zscoder wants to generate an input file for some programming competition problem. His input is a string co…