DELETE pos— delete a character number pos (1 ≤ pos ≤ |s|) from the string s. At that the letters shift together and the length of the string decreases by 1. REPLACE pos ch— the letter in the position pos of the line s is replaced by ch (1 ≤ pos ≤ |...
Codeforces 56D Changing a String (DP) 题意:你可以对字符串s进行3种操作: 1,在pos位置插入字符ch。 2,删除pos位置的字符。 3,替换pos位置的字符为ch。 问最少需要多少次操作可以把字符s变成字符s1? 思路: 设dp[i][j]为字符串s的前i个字符替换成s1的前j个字符的最小花费。则有三种转移: 1:dp[i ...
}else{ dfs(n-1,m-1);if(a[n]!=b[m]) printf("REPLACE %d %c\n",m,b[m]); } }intmain(){ scanf("%s",a+1);n=strlen(a+1); scanf("%s",b+1);m=strlen(b+1);for(inti=0;i<=n;i++)for(intj=0;j<=m;j++) f[i][j]=0; f[0][0]=0;for(inti=1;i<=n;i++) ...
void dfs(int a, int b){ if(a == 0 && b==0)return ; if(s[a] == t[b] && dp[a-1][b-1] == dp[a][b]) dfs(a-1, b-1); else { if(a && dp[a-1][b] +1 == dp[a][b]) { P = node(1, a); P.put(); dfs(a-1, b); } else if(b && dp[a][b-1] ...
每行包括两个string。设第一个为用户的oldName,第二个为用户的newName,用newName 替换旧的oldName,可进行重复替换。最后输出用户的第一个Name 和最新的Name。举例:Input: “` 5 Misha ILoveCodeforces Vasya Petrov Petrov VasyaPetrov123 ILoveCodeforces MikeMirzayanov Petya Ivanov...
importjava.util.HashMap;importjava.util.Scanner;publicclassB501{publicstaticvoidmain(String[]args){Scanner sc=newScanner(System.in);int t=sc.nextInt();HashMap<String,String>map=newHashMap<>();while(t-->0){String a=sc.next();String b=sc.next();if(map.containsKey(a)){map.put(b,map...
Misha hacked the Codeforces site. Then he decided to let all the users change their handles. A user can now change his handle any number of times. But each new handle must not be equal to any handle that is already used or that was used at some point. ...
Codeforces Educational Codeforces Round 77 (Rated for Div. 2)(D. A Game with Traps) D. A Game with Traps 题意: 给你一群士兵(每个士兵有灵活值aia_iai) 给出地雷的信息(地雷的位置,解锁地雷位置,士兵躲避地雷的最低灵活值) 你是将军,可以到解锁地雷的位置解锁地雷然后再回去带兵通过雷区。 问...
CodeForces - 1230D(思维+位运算) 2019-12-05 15:36 − 题意https://vjudge.net/problem/CodeForces-1230D 要组建一个小组,要求小组中每个人都不比所有人强,当一个人懂得一个算法但是另一个不懂那么前者认为他比后者强。所以这个小组要满足一个人懂得算法必定有另一个人全懂。每个人的技能是不同的,...
#include<string.h> using namespace std; #define ll int #define N 1010 char s[N], t[N]; int dp[N][N], n, m; // 0为插入 1为删除 2 3为替换 struct node{ int op; int pos; char c; node(int A=0,int E=0,char D=0):op(A),pos(E), c(D){} ...