ICode9

精准搜索请尝试: 精确搜索
  • 字符串题目:破坏回文串2021-12-20 18:02:02

    文章目录 题目标题和出处难度题目描述要求示例数据范围 解法思路和算法代码复杂度分析 题目 标题和出处 标题:破坏回文串 出处:1328. 破坏回文串 难度 4 级 题目描述 要求 给你一个由小写英语字母组成的回文字符串 palindrome

  • 1136 A Delayed Palindrome2021-12-11 10:59:09

    采用大整数加法计算。 #include<bits/stdc++.h> using namespace std; string s; void add(string x){ int flag=0; for(int i=x.length()-1;i>=0;i--){ int temp=s[i]-'0'+x[i]-'0'+flag; flag=0; if(temp>9){ temp=temp-10; flag=1;

  • codeforces D. Palindrome Degree(hash)2021-11-20 19:33:47

    开始使用Palindromic Characteristics的方式来计算dp(i,j)的回文度,然后统计dp所有(0,j)提示空间超过限制。因为是需要计算所有前缀的回文度之和。由于回文度关系有dp(i) = 1+dp(i/2),如果s[0..i]是回文串。分别计算从0到i和从i到0的哈希值,如果两个哈希值相等,说明是回文串,就用上面

  • P2890 [USACO07OPEN]Cheapest Palindrome G 题解2021-11-16 12:32:38

    link P2890 [USACO07OPEN]Cheapest Palindrome G sol 定义 \(F[i][j]\) 表示从为从\(i\)到\(j\)这段区间被修正为回文串的最小花费 然后考虑转移,若\(a[i]==a[j]\) 那么直接转移 否则考虑加减 \(i+1\) 或 \(j-1\) code #include<bits/stdc++.h> using namespace std; const int max

  • 算法: 验证回文680. Valid Palindrome II2021-11-06 09:04:51

    680. Valid Palindrome II Given a string s, return true if the s can be palindrome after deleting at most one character from it. Example 1: Input: s = "aba" Output: true Example 2: Input: s = "abca" Output: true Explanation: You could

  • 算法入门经典P49-3-7(回文串和镜像串)2021-11-03 10:31:25

    #include<iostream> #include<string.h> #include<ctype.h> using namespace std; const char* rev = "A 3 HIL JM O 2TUVWXY51SE Z 8 "; const char*msg[] = {"not a palindrome","a regular parlindrome","a m

  • Palindrome Number2021-10-10 15:03:14

    Problem Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of converting the integer to string, note the restriction of u

  • leetcode5 longest palindrome substring 之manacher算法2021-10-06 15:01:57

    这个题的常规解法大家可以看答案,还是很简单直接的。这里我想用自己比较易懂的语言,讲一下可以达到o(n)的manacher算法,希望可以帮助有兴趣的盆友思考。 首先要引入臂长的概念,比如abcba,以c为中心,那么臂长是2。 接下来我们考虑,关于某中心回文上对称的两个点,比如上面abcba上的两个

  • [luogu] CF7D Palindrome Degree 字符串hash+dp2021-10-02 13:02:13

    前言 怎么字符串hash 这么难啊(一堆hash公式)QAQ 代码借鉴 : https://www.luogu.com.cn/blog/yhttcr/solution-cf7d 传送门 : https://www.luogu.com.cn/problem/CF7D 思路 题目很简单明了 操作无非就两步 判断子串是否回文dp处理所有前缀之和 第二步按题意来非常简单 但是第

  • 洛谷 P2890 [USACO07OPEN]Cheapest Palindrome G(区间dp)2021-09-12 21:02:41

    传送门 解题思路 很经典的区间dp问题。 我们可以发现删除和添加本质上是一样的。 所以可以直接对删除费用和添加费用取min。 跑一遍区间dp即可。 注意在读入string时,不能一位一位读,会RE。 正确的处理方法是直接cin>>S,或者用char数组代替string。 AC代码 #include<cstdio> #includ

  • Leetcode No. Palindrome Number回文数(c++实现)2021-08-14 16:31:21

    1. 题目 https://leetcode.com/problems/palindrome-number/ 2. 分析 这一题可以将数字直接反转,如果反转后数字和原数字相同,则一定是回文数。当然对于负数可以直接返回false 具体代码如下: class Solution { public: bool isPalindrome(int x) { if (x < 0) {

  • codeforces 1512 C. A-B Palindrome(1200,回文)2021-08-04 23:58:10

    链接:https://codeforces.com/problemset/problem/1512/C 题意:构造满足条件的字符串 题解:没啥解,就硬凑;具体看代码; 代码: #include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { int t; cin >> t; while (t--) { int a, b, n; cin >> a >>

  • Leetcode No.125 Valid Palindrome(c++实现)2021-07-31 19:33:26

    1. 题目 1.1 英文题目 Given a string s, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. 1.2 中文题目 给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写。 1.3输入输出 输入 输出 s = "A ma

  • LeetCode每日一题(Split Two Strings to Make Palindrome)2021-07-29 15:29:35

    You are given two strings a and b of the same length. Choose an index and split both strings at the same index, splitting a into two strings: aprefix and asuffix where a = aprefix + asuffix, and splitting b into two strings: bprefix and bsuffix where b =

  • 306. Check If Linked List Is Palindrome2021-07-14 17:04:57

    Given a linked list, check whether it is a palindrome. Examples: Input:   1 -> 2 -> 3 -> 2 -> 1 -> null output: true. Input:   1 -> 2 -> 3 -> null   output: false. Requirements: Space complexity must be O(1) 思路:找到中点,在reverse,比较reve

  • CF1512C A-B Palindrome2021-07-13 10:30:08

    原题链接:洛谷 题目描述 You are given a string s consisting of the characters ‘0’, ‘1’, and ‘?’. You need to replace all the characters with ‘?’ in the string s by ‘0’ or ‘1’ so that the string becomes a palindrome and has exactly a characters

  • Codeforces Round #721 (Div. 2) B. Palindrome Game (easy and hard version) (思维 + 简单博弈)2021-07-09 22:32:40

    easy version 传送门 hard version 传送门 题意: 给定一个由0和1组成的字符串,进行如下两种操作; 将0变为1,花费1代价;如果字符串不是回文串,则选手可以进行一次翻转,花费0代价(简单问题版本中字符串为回文串); Alice先手; 思路: 首先是简单版本,统计0的个数 0的个数为偶数,Alice先手破坏回

  • [LeetCode] 1147. Longest Chunked Palindrome Decomposition 段式回文2021-07-04 05:31:06

    You are given a string text. You should split it to k substrings (subtext1, subtext2, ..., subtextk) such that: subtexti is a non-empty string. The concatenation of all the substrings is equal to text (i.e., subtext1 + subtext2 + ... + subtextk 

  • 云演CTF: 009.php_for_fun2021-06-10 09:03:32

    云演CTF: 009.php_for_fun 作者: admin时间: 2021-05-31分类: 云演CTF 在首页的返回头中获得hint文件名,内容是"Please input a parameter as number!!"尝试传入参数"number",返回"Please input a parameter as number!!",同时返回头中包含hint2,内容是"$req['number']==strv

  • B2. Palindrome Game (hard version)(记忆化搜索)2021-06-04 19:33:37

    LINK A l i c e Alice Alice和 B

  • Palindrome Partitioning LightOJ - 1044(区间 dp)2021-05-30 12:33:24

    题目传送门 题意 给我们一个字符串 S,问可以将 S 分割成几个子区间,要求分割出的每个子区间的都是回文串,输出最小分割成的区间的数量。 思路 这题明显是区间 dp,设出来状态转移方程:dp [i][j] 表示将 [i, j] 这个区间分割成的最少会问区间的数量。考虑状态转移:[i, j] 这个区间的

  • Codeforces Round #721 (Div. 2)2021-05-25 21:34:48

    B1. Palindrome Game (easy version) 博弈,如果有偶数个0,A选完后,B选对称的,A就只能再选。直到最后剩2个,此时A选完后,B翻转。 如果有奇数个0,A首先选中间的0,然后情况类似。 1 char s[N]; 2 int main() 3 { 4 ios::sync_with_stdio(false); cin.tie(nullptr); 5 6 in

  • CodeForces 1335E2 : Three Blocks Palindrome (hard version) 二分 + 思维2021-05-24 21:00:26

    传送门 题目描述 分析 最近人有点颓废,状态不好,菜到1800的题都切不出来,唉,不能再消沉了 这个题我们贪心的去想,我们去过枚举了前面一个区间的话,那么最后那个区间的左端点一定是越靠右越好,这样我们中间可以选择的部分就越多,所以我们可以去枚举第一个区间的右端点,二分找第三个区

  • 题解 CF1527B1【Palindrome Game (easy version)】2021-05-24 15:03:37

    概述 题号 难度 \(AC\)时间及记录 \(\texttt{CF1527B1}\) \(\texttt{洛谷难度:暂无评定}\) \(\texttt{On 2021/05/22}\) 解析 这道题目题目意思不难理解, 我们关注题目中给出了一个性质:给入的字符串回文。 那么我们可以这样考虑: (如果刚开始就全部是 \(1\),那么是 \(DRAW

  • C. A-B Palindrome2021-05-23 10:01:40

    题意: 给出一串由0,1,?组成的字符串,要求把?变成0或1,保证字符串为回文字符串且满足有a个0,b个1。 题解: 在cf上看到的大佬写的极短的题解(某菜写出来也太长了)。 ACcode: int main() { int t; cin >> t; while (t--) { int a, b; string s; cin >>

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有