Codeforces C - String Reconstruction】的更多相关文章

题目链接:http://codeforces.com/contest/828/problem/C C. String Reconstruction time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Ivan had string s consisting of small English letters. However, hi…
C - String Reconstruction 方法一:把确定的点的父亲节点设为下一个点,这样访问过的点的根节点都是没访问过的点. 代码: #include<bits/stdc++.h> using namespace std; ; ]; ]; int Find(int x) { return x==fa[x]?x:fa[x]=Find(fa[x]); } int main() { ;i<N*;i++)fa[i]=i; int n,t,x; scanf("%d",…
String Reconstruction Ivan had string s consisting of small English letters. However, his friend Julia decided to make fun of him and hid the string s. Ivan preferred making a new string to finding the old one. Ivan knows some information about the s…
题意:给你n个串,给你每个串在总串中开始的每个位置,问你最小字典序总串. 思路:显然这道题有很多重复填涂的地方,那么这里的时间花费就会特别高. 我们维护一个并查集fa,用fa[i]记录从第i位置开始第一个没填涂的位置,那每次都能跳过涂过的地方.每次填完当前格就去填find(fa[i + 1]). ps:一定要合并,不然超时. 代码: #include<stack> #include<vector> #include<queue> #include<set>…
LINK 题目大意 给你n个串和在原串中的出现位置,问原串 思路 直接跑肯定是GG 考虑怎么优化 因为保证有解,所以考虑过的点我们就不再考虑 用并查集维护当前每个点之后最早的没有被更新过的点 然后就做完了,很巧妙对吧 c++//Author: dream_maker #include<bits/stdc++.h> using namespace std; //---------------------------------------------- //typename typedef lo…
C. String Reconstruction 题目连接: http://codeforces.com/contest/828/problem/C Description Ivan had string s consisting of small English letters. However, his friend Julia decided to make fun of him and hid the string s. Ivan preferred making a new strin…
题目链接:String Similarity 题意: 首先题目定义了两个串的相似(串的构成是0.1),如果两个串存在对于一个下标k,它们的值一样,那么这两个串就相似 然后题目给你一个长度为2n-1的串,我们设下标从1开始,那么[1,n],[2,n+1],[3,n+2]...[n,2n-1]每一个都是一个长度为n的串,你需要找出来长度为n的串,使得这个串和[1,n],[2,n+1],[3,n+2]...[n,2n-1]这些串都相似 题解: 你会发现,只需要输出原长度为2n-1串的下标1,3,5,7…
C. String Reconstruction time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Ivan had string s consisting of small English letters. However, his friend Julia decided to make fun of him and hid…
CF1400-C. Binary String Reconstruction 题意: 对于一个二进制字符串\(s\),以及一个给定的\(x\),你可以通过一下操作来得到字符串\(w\): 对于字符串\(s\)的第\(i\)位, 1. 如果\(i-x\)有意义并且\(s[i-x]==1\)那么\(w[i]=1\) ; 2.如果\(i+x\)有意义并且\(s[i+x]==1\),那么\(w[i]=1\); 如果上面两条都不符合,那么\(w[i]=0\). 现在题目给出你字符串\(w\)和\(x\),…
http://codeforces.com/contest/828/problem/C 并查集的神奇应用. #include<bits/stdc++.h> using namespace std; const int maxn=10000005; char s[maxn]; string ss[100000]; vector<int> g[100000]; int fa[maxn]; int findfa(int x) { if (fa[x]==x) return x; else…