CF1320D Reachable Strings】的更多相关文章

题解-Reachable Strings 前置知识: \(\texttt{Hash}\) Reachable Strings 给一个长度为 \(n\) 的 \(\texttt{01}\) 串 \(s\),可以让 \(s\) 中的 \(\texttt{110}\) 和 \(\texttt{011}\) 互相转换.\(q\) 次询问,每次给定两个 \(s\) 的子串 \(s_{l_1\sim l_1+len-1}\) 和 \(s_{l_2\sim l_2+len-1}\),问两个串是否可以互相变换得…
题目大意 给定一个长为\(n\)的01串\(S\),每次你可以对一个串的三个连续位置做:\(011 \rightarrow 110\),\(110 \rightarrow 011\)的操作. 有\(q\)次询问,每次询问给出两个长度相等的子串,问是否能从一个串变到另一个串. 题解 首先,我们发现操作不改变\(1\)的个数.所以可以先用前缀和判断\(1\)的个数是否相等. 如果某个字符串不出现相邻的两个\(1\),那么容易得到你无法做任何有效的操作,就直接判断是否相等.这一步可以用hash或sa或…
  A - Journey Planning 题意: 有一列共 n 个城市, 每个城市有美丽值 b[i], 要访问一个子序列的城市, 这个子序列相邻项的原项数之差等于美丽值之差, 求最大的美丽值总和. 思路: 对于一个合法的子序列, b[i] - i 结果是一个定值, 统计该值取最大. view code #include <bits/stdc++.h> using namespace std; #define ll long long #define inc(i, l, r) for (in…
第一次打虚拟赛. CF 传送门 T1:Contest for Robots 统计 \(r[i]=1\) 且 \(b[i]=0\) 的位数 \(t1\) 和 \(r[i]=0\) 且 \(b[i]=1\) 的位数 \(t2\). 两个数都为 \(0\) 或都为 \(1\) 时没有贡献. 若 \(t1=0\),则 \(r\) 序列不管乘多大的 \(p\) 也不会比 \(b\)序列更大,所以直接输出 \(-1\). 否则,我们考虑将 \(r[i]=0\) 且 \(b[i]=1\) 的位置的 \(p[i…
March 18, 2016 Problem statement: https://www.hackerrank.com/challenges/two-strings/submissions/code/18506948 Julia likes to try a new way to train herself to expand C#/ C++ / Java / JavaScript languages, by reading the solutions, followed up with so…
StackOverFlow排错翻译 - Python字符串替换: How do I replace everything between two strings without replacing the strings? 原创连接: Python字符串替换 问题: Python:如何将两字符串之间的内容替换掉? I have this string(问题源码): str = ''' // DO NOT REPLACE ME // Anything might be here. Numbers…
Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be arbitrarily large and are non-negative. Converting the input string to integer is NOT allowed. You should NOT use internal library su…
Given two non-negative numbers num1 and num2 represented as string, return the sum of num1 and num2. Note: The length of both num1 and num2 is < 5100. Both num1 and num2 contains only digits 0-9. Both num1 and num2 does not contain any leading zero.…
Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list of strings. Machine 1 (sender) has the function: string encode(vector<string> strs) { // ... your…
Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which forms the sequence: "abc" -> "bcd" -> ... -> &quo…