Codeforces828 C. String Reconstruction】的更多相关文章

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…
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…
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",…
题目链接: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…
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…
题目链接: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…
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\),…
并查集维护和我这个位置的字母连续的已经被填充的字母能到达的最右边的第一个还没有填充的位置,然后把这个位置填上应该填的东西,然后把这个位置和下一个位置连接起来,如果下一个位置还没有填,我就会把下一个位置填上,如果填过了,就会跳到后面的还没有填的地方 #include<map> #include<set> #include<ctime> #include<cmath> #include<stack> #include<queue> #in…
题意:给你n个串,给你每个串在总串中开始的每个位置,问你最小字典序总串. 思路:显然这道题有很多重复填涂的地方,那么这里的时间花费就会特别高. 我们维护一个并查集fa,用fa[i]记录从第i位置开始第一个没填涂的位置,那每次都能跳过涂过的地方.每次填完当前格就去填find(fa[i + 1]). ps:一定要合并,不然超时. 代码: #include<stack> #include<vector> #include<queue> #include<set>…
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…
在每个给出的子串的起始位置打个标记,记录的是从这里开始的最长子串. 然后输出的时候就扫,如果遇到开始位置,就从这里开始输出,如果其后被更长的覆盖,就跳转到更长的串进行输出. 如果位置没被覆盖,就输出'a'. #include<cstdio> #include<string> #include<algorithm> #include<iostream> using namespace std; string s[100010]; int n,m,p[20000…
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 string s. Namely, he re…
http://codeforces.com/contest/828/problem/C [题意] [思路] 因为题目保证一定有解,所有优化时间复杂度的关键就是不要重复染色,所以我们可以用并查集维护区间,把确定的点的父亲节点设为下一个点,这样访问过的点的根节点都是没访问过的点. 与上一题是同样的思路,用并查集路径压缩, 要求字典序最小,可以最初给每个字符都赋值'a' 判断字符串最长是多少,最后加'\0' [Accepted] #include<iostream> #include<cstd…
[Link]:http://codeforces.com/contest/828/problem/C [Description] 让你猜一个字符串原来是什么; 你知道这个字符串的n个子串; 且知道第i个字符t[i],在k[i]个位置出现过; 且告诉你这k[i]个位置在哪里; 数据不会产生矛盾; 让你输出最终的字符串,输出字典序最小的那个; [Solution] 对于输入的n个子串; 对于每个位置; 看看那个位置有没有子串之前出现过,没有的话,就放在那个位置; 否则,如果当前这个子串ti的长度比原…
题目链接:http://codeforces.com/contest/828/problem/C 题解:有点意思的题目,可用优先队列解决一下具体看代码理解.或者用并查集或者用线段树都行. #include <iostream> #include <cstring> #include <queue> #include <vector> #include <cstdio> #include <map> #include <strin…
LINK 题目大意 给你n个串和在原串中的出现位置,问原串 思路 直接跑肯定是GG 考虑怎么优化 因为保证有解,所以考虑过的点我们就不再考虑 用并查集维护当前每个点之后最早的没有被更新过的点 然后就做完了,很巧妙对吧 c++//Author: dream_maker #include<bits/stdc++.h> using namespace std; //---------------------------------------------- //typename typedef lo…
题意:给你一个字符串\(s\),原字符串为\(w\),如果\(i>x\)且\(w_{i-x}=1\),那么\(s_{i}=1\),如果\(i+x\le n\)且\(w_{i+x}=1\),那么\(s_{i}=1\),否则\(s_{i}=0\).求\(w\)的一种可能的情况. 题解:对于\(s\)中的\(0\),我们知道,它左右两边距离\(x\)的地方一定都是\(0\),所以我们先假设\(w\)全为\(1\),然后再更新\(s_{i}\)为\(0\)的情况,最后判断一下\(1\)的情况在\(w\)…
哇这是我打的第一场cf,第一题都wa了无数次,然后第二题差几分钟交 ,第二天一交就AC了内心是崩溃的.果然我还是太菜l.... A. Restaurant Tables time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In a small restaurant there are a tables for one person…
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…
codeforces 423 A. Restaurant Tables [水题] //注意,一个人选座位的顺序,先去单人桌,没有则去空的双人桌,再没有则去有一个人坐着的双人桌.读清题意. #include <cstdio> #include <algorithm> #include <cstring> using namespace std; int n, a, b, bb, x; int main() { ; scanf("%d%d%d", &am…
Codeforces Round #423 (Div. 1, rated, based on VK Cup Finals) A.String Reconstruction B. High Load C. DNA Evolution 题意:给定一个只包含A,T,C,G的字符串S,有如下两种操作 1)修改一个点的字母. 2)给定一个字符串e ($\left | e \right |\leq 10$),生成一个由e重复组成的新串,eee...,问$S_{l..r}$中有几个字母跟这个新的字符串一一对应…
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…
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…
CF640 div4 草 迟到半个月的补题 真正的懒狗 再懒就无了 D. Alice, Bob and Candies 题意:n个数字,奇数时间从左侧删数字,偶数时间从右侧删数字,每次删的数字之和必须大于上次的.问最多删多少次和左边删除数字和与右边删除数字和. 题解:很简单的模拟题,初始情况特判即可,不知道当时为什么没做出来 #include<iostream> using namespace std; int can[1005]; int main() { int t; cin >&g…
比赛链接:https://codeforces.com/contest/1400 A. String Similarity 题意 给出一个长 $2n-1$ 的二进制串 $s$,构造一个长 $n$ 的字符串,使其与 $s$ 的每个长 $n$ 的子串至少有一处字母相等. 题解 长 $n$ 的子串恰有 $n$ 个,每个子串取一位即可. 代码 #include <bits/stdc++.h> using namespace std; void solve() { int n; string s; ci…
比赛链接:https://codeforces.com/contest/1352 A - Sum of Round Numbers 题意 将一个十进制数的每一个非零位分离出来. 代码 #include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; int n = s.size(); vector<string> ans; for (int i = n - 1; i >…
catalog . INTRODUCTION . THE PROCESS IMAGE . THE CORE IMAGE . EXECUTABLE RECONSTRUCTION . FAILURES IN RECONSTRUCTION . USES OF RECONSTRUCTION . Helper Tools . Code For New Linux Kernel 1. INTRODUCTION This article documents the results from experimen…
Ikki's Story I - Road Reconstruction Time Limit: 2000MS   Memory Limit: 131072K Total Submissions: 7971   Accepted: 2294 Description Ikki is the king of a small country – Phoenix, Phoenix is so small that there is only one city that is responsible fo…
摘要 : 最近在博客园里面看到有人在讨论 C# String的一些特性. 大部分情况下是从CODING的角度来讨论String. 本人觉得非常好奇, 在运行时态, String是如何与这些特性联系上的. 本文将侧重在通过WinDBG来观察String在进程内的布局, 以此来解释C# String的一些特性. 问题 C# String有两个比较有趣的特性. String的恒定性. 字符串横定性是指一个字符串一经创建,就不可改变.那么也就是说当我们改变string值的时候,便会在托管堆上重新分配一块…
本编主要介绍String 字符串对象. 目录 1. 介绍:阐述 String 对象的说明以及定义方式. 2. 实例属性:介绍 String 对象的实例属性: length. 3. 实例方法:介绍 String 对象的实例方法:charAt.charCodeAt.concat.indexOf等方法. 1. 介绍 1.1 说明 String 对象,对字符串进行操作,如:截取一段子串.查找字符串/字符.转换大小写等等. 1.2 定义方式 1.2.1 new String(Value) 构造函数:返回一…