Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.util.Scanner; public class Main1 { private static int hammingDist(String s1, String s2) { int dist = 0; for (int i = 0; i < s1.length(); i++) { if (s1.charAt(i) != s2.charAt(i)) dist++; } return dist; } public static void main(String[] args) { Scanner in = new Scanner(Sy...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.io.*; import java.util.*; public class CF156A { static Scanner in; static PrintWriter out; public static void main(String[] args) { in = new Scanner(System.in); out = new PrintWriter(System.out); System.out.println(foo(in.next(), in.next())); } public static i...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; inline void pisz(int n) { printf("%d\n", n); } int main() { string s, u; cin >> s >> u; string dummy(u.size() - 1, '@'); s = dummy + s + dummy; int res = u.size(); for (int i = 0; i + u.size() <= s.size(); ++i) { int mis = 0; for (int j = 0; j < u.size()...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import static java.lang.Math.*; import java.io.*; import java.math.*; import java.util.*; public class TaskA { MyScanner in; PrintWriter out; String s, t; void load() throws Exception { s = in.nextToken(); t = in.nextToken(); } void solve() throws Exception { int ans = Integer.MAX_VALUE; for (int shift...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; char s[2012], t[2012]; int i, j, k, n, m; int main() { fgets(s, sizeof(s), stdin); fgets(t, sizeof(t), stdin); n = strlen(s); if (s[n - 1] < 'a' || s[n - 1] > 'z') { s[n - 1] = '\0'; n--; } m = strlen(t); if (t[m - 1] < 'a' || t[m - 1] > 'z') { t[m...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; int main(void) { string s, t; int ss, tt, i, d, best = 0; cin >> s >> t; ss = (int)s.size(); tt = (int)t.size(); for (d = 2010; d > -2010; d--) { int cnt = 0; for (i = 0; i < ss; i++) { if (i + d > -1 && i + d < tt && s[i] == t[i + d]) cnt++; }...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.util.*; import java.io.*; public class Message implements Runnable { public void solve() throws IOException { char[] s = nextToken().toCharArray(); char[] a = nextToken().toCharArray(); StringBuilder temp = new StringBuilder(); for(int ...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
s = raw_input() u = raw_input() s = ''.join(['#' * len(u), s, '#' * len(u)]) ans = len(u) for i in xrange(len(s) - len(u)): ans = min(ans, sum(1 for c, d in zip(u, s[i:]) if c != d)) print ans
PYTHON
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s1 = sc.next(), s2 = sc.next(); int ans = 0x3f3f3f3f; for (int i = 0; i < s2.length(); i++) { int cnt = 0; ...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9 + 7; const int N = 2e5 + 10; int check(string &&s1, string &s2) { int n = min(s1.length(), s2.length()); int ret = 0; for (int i = 0; i < n; i++) { if (s1[i] != s2[i]) ret++; } return ret + max(0, (int)s2.length() - n); } int main() {...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; int main() { string s, t; cin >> s >> t; s = string(t.size(), '#') + s + string(t.size(), '#'); int l = 0, r = t.size() - 1; int res = t.size(); for (; r < s.size();) { int cnt = t.size(), j = 0; for (int i = l; i < r + 1; ++i) { cnt -= s[i] == t[j...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.StreamTokenizer; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author Tibor */ public class test { static StreamTokenizer in = new StreamTokenizer...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.io.*; import java.util.*; public final class message { static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); static FastScanner sc=new FastScanner(br); static PrintWriter out=new PrintWriter(System.out); static String s1=""; static int compare(char[] a,char[] b,int last...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.io.*; import java.util.Arrays; public class Main{ public static void main(String[] args) throws Exception { String s = inB.readLine(); String u = inB.readLine(); int min = 2001; char[] f = new char[u.length()]; Arrays.fill(f, '#'); s = String.valueOf(f) + s + String.valueOf(f); for(i...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; string s; string u; int n, m, mans = 0, ans = 0; int main() { cin >> s >> u; m = s.size(); n = u.size(); for (int i = 1; i < min(m, n); i++) { for (int j = 0; j < i; j++) if (s[j] == u[n - i + j]) ans++; mans = max(ans, mans); ans = 0; for (int...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; char a[10010]; char b[10010]; vector<int> v[10010]; int mp[10010]; void solve() { scanf("%s%s", a, b); int n = strlen(a); int m = strlen(b); int minn = 10000000; for (int i = 0; i < n; i++) { int ans = 0; for (int j = i;; j++) { if (j - i == m || j =...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:65777216") using namespace std; bool OUTPUT_TO_FILE = 0; int main() { string s1, s2; cin >> s1 >> s2; string s; for (int i(0); i < (s2.size()); i++) s.push_back('.'); s += s1; for (int i(0); i < (s2.size()); i++) s.push_back('.'); int res = s2.size(...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int lenu, lent, i, j, ans; string s, u; while (cin >> s >> u) { lenu = u.length(); string t; for (i = 0; i < lenu; i++) t = t + " "; t = t + s; for (i = 0; i < lenu; i++) { t = t + " "; } lent = t.length(); ans = 0; ...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; string s, t; int main() { cin >> s >> t; for (int i = 0; i < t.size(); i++) s = "!" + s + "!"; int ans = t.size(); for (int i = 0; i + t.size() <= s.size(); i++) { int cur = 0; for (int j = 0; j < t.size(); j++) { if (s[i + j] != t[j]) { cur++;...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author evgeniy */ public class CodeForces { public static void main(String[] args) { try { BufferedReader br = new Buffered...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.math.BigInteger; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; long long const MAX = 2147483647, REALMAX = 9223372036854775806; const int N = 2e3; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string s, u, s2; int sum = 0, mini = N; cin >> s >> u; for (long long i = (0); i < (N); i++) s2 +=...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; int res; int DN[2005][2005]; char S1[2005], S2[2005]; int main() { scanf("%s%s", S1 + 1, S2 + 1); int uz1 = strlen(S1 + 1); int uz2 = strlen(S2 + 1); for (int i = 1; i <= uz1; i++) for (int j = 1; j <= uz2; j++) { DN[i][j] = DN[i - 1][j - 1] + (S1[i] == S2...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author lwc62...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.LinkedList; import java.util.List; /** * Author: Vasiliy Homutov - vasiliy.homutov@gmail.com * Date: 02.05.12 * See: ht...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; int main() { string s, t; cin >> s >> t; int a = s.size(), b = t.size(); int ans = 0; for (int i = -2010; i <= 2010; i++) { int num = 0; for (int j = 0; j < a; j++) { if (j + i >= 0 && j + i < b && s[j] == t[j + i]) num++; } ans = max(ans, nu...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.util.*; public class C { static int n, m; static int[][] dp; static char[] a, b; public static void main(String[] args) { Scanner in = new Scanner(System.in); String s = in.next(); String u = in.next(); for (int i = 0; i < u.length(); i++) s = "1...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; const int INF = INT_MAX; const long long INFL = LLONG_MAX; const int output_precision = 15; const long double pi = acos(-1); const bool debug = true; int f[3000][3000]; int main() { ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed; cout....
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3f; const int MOD = 1e9 + 7; const int N = 1e6 + 7; char s1[N], s2[N]; string a, b; void Init() { a = s1, b = s2; a = string(2000, '*') + a + string(2000, '*'); } int Solve() { int ans = INF; for (in...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import sys import re s = raw_input() u = raw_input() s = '.'*(len(u)-1)+s+'.'*(len(u)-1) def diff(src, pat): k = 0 for i in xrange(len(src)): if src[i]!=pat[i] or src[i] == '.': k+=1 return k ml = len(u) for i in xrange(len(s)-len(u)+1): tl = diff(s[i:i+len(u)], u) if tl < ml: ml = tl prin...
PYTHON
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.Scanner; public class MessageProblem { public static BufferedReader openR...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); string str; string req; cin >> str; cin >> req; int lstr = str.length(); int lreq = req.length(); for (int i = 0; i < lreq; ++i) { str = "X" + str; } for (int i = 0; i < lreq; ++i) { str += "X"; } in...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> const int INT_INF = 0x3f3f3f3f; const int INT_M_INF = 0x7f7f7f7f; const long long LL_INF = 0x3f3f3f3f3f3f3f3f; const long long LL_M_INF = 0x7f7f7f7f7f7f7f7f; const double pi = acos(-1.0); using namespace std; inline void debug(char ch) { for (int __ii = 0; __ii < 20; ++__ii) putchar(ch); pr...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; int main() { string s, u; cin >> s >> u; for (int i = 0; i < u.size(); ++i) s = '$' + s + '$'; int ans = u.size(); for (int i = 0; i + u.size() <= s.size(); ++i) { int cur = 0; for (int j = 0; j < u.size(); ++j) if (s[i + j] != u[j]) ++cur; ans =...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.util.*; import java.io.*; import java.awt.Point; import static java.lang.Math.*; public class P156A { public static void main(String[] args) throws Exception { Scanner in = new Scanner(System.in); String s = in.next(); String t = in.next(); int ans = t.length(); ...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; string extend_string(string s, int n) { string appendix = ""; for (int i = 0; i < n; ++i) appendix += "$"; return appendix + s + appendix; } int count_diff(string str1, string str2) { int n = str1.length(); int counter = 0; for (int i = 0; i < n; ++i) { if (...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; import java.util.StringTokenizer; public class C { BufferedReader bf = new BufferedRe...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.io.*; import java.util.*; public class Message { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String s = in.readLine(); String u = in.readLine(); int sl = s.length(); int ul = u.length(); int end = 1; i...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.io.*; import java.util.*; import java.lang.*; public class Rextester{ static int findAns(String a,String b,int abeg,int aend,int bbeg,int bend){ int count = 0; for(int i=abeg,j=bbeg;i<=aend&&j<=bend;i++,j++){ if(a.charAt(i)==b.charAt(j)){ count++; ...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; char S0[2100]; char S[10100]; char U[2100]; int n, m; int main() { gets(S0); gets(U); n = strlen(S0); m = strlen(U); int c = m - 1; for (int i = 0; i < (n); ++i) { S[i + c] = S0[i]; } for (int i = 0; i < (c); ++i) { S[i] = S[c + n + i] = '.'; } n...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#!/usr/bin/env python import sys import pdb s = sys.stdin.readline().strip() t = sys.stdin.readline().strip() max = 0 def matches(a,b): """docstring for matches""" num = 0 for i in xrange(min(len(a), len(b))): if a[i] == b[i]: num += 1 return num for i in xrange(len(s)): temp = matches(s[i:], t) if temp ...
PYTHON
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
/** * User: Sergey Epifanov * Date: 07.05.12 */ import java.io.*; import java.util.Scanner; public class E157CMessage { public static void main(String args[]) throws IOException { new E157CMessage().run(); } private Scanner in; private PrintWriter out; pri...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; string s1, s2, s3; int main() { ios::sync_with_stdio(0); cin >> s1 >> s2; int n = s1.length(); int m = s2.length(); for (int i = 0; i < m; i++) { s3.push_back('?'); } s1 = s3 + s1; n = s1.length(); int ans = 500000; for (int i = 0; i < n; i++) { ...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; char ar[2005], br[2005]; int main(void) { scanf("%s %s", &ar, &br); int si1 = strlen(ar); int si2 = strlen(br); int mx = 0, counter = 0; for (int i = -2000; i <= 2000; i++) { counter = 0; for (int j = 0; j < si2; j++) { if (j + i >= 0 && j + i < si1)...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.util.Arrays; import java.util.Scanner; public class Message { public static void main(String[] args) { Scanner sc=new Scanner(System.in); String a=sc.next(); String b=sc.next(); int maxlen=Math.max(a.length(), b.length()); int minlen=Math.min(a.length(), b.length()); char[] s=new char [max...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
s = raw_input() u = raw_input() n = len(s) m = len(u) best = m for i in range(1 - m, n): cnt = 0 for j in range(m): if i + j < 0 or i + j >= n or s[i + j] != u[j]: cnt += 1 best = min(best, cnt) print best
PYTHON
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#!/usr/bin/env python2 # -*- coding: utf-8 -*- import sys ifs = sys.stdin ofs = sys.stdout def number_of_differences(A,B): n = len(A) N = 0 for i in range(n): if A[i] != B[i]: N += 1 return N def solve(s,u): n = len(s) m = len(u) s = '%s%s%s' % ('.'*m, s, '.'...
PYTHON
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.util.Scanner; /** * @author * Date: */ public class Message { public final static String PSEUDO_SYMBOLS; static { String tmp = new String(); for (int i = 0; i < 2000; i++) { tmp += "@"; } PSEUDO_SYMBOLS = tmp; } public static void main(Stri...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
from sys import stdin, stdout first, second = stdin.readline().strip(), stdin.readline().strip() n, m = len(first), len(second) first = '#' * m + first + '#' * m ans = float('inf') for i in range(n + m): cnt = 0 for j in range(m): if first[i + j] != second[j]: cnt += 1 ans =...
PYTHON3
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; double eps = 1e-9; const int INF = 1e9 + 7; const int MAXN = int(3e5 + 7); int n, m, dp[2007][2007], ans; string second, t; int main() { cin >> second >> t; n = second.size(), m = t.size(); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (seco...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; const int INF = 1000 * 1000 * 1000; int main() { string s, u; cin >> s >> u; int lenu = u.length(); s = string(2000 + 1, '#') + s + string(2000 + 1, '#'); int lens = s.length(); int ans = INF; for (int i = 0; i + lenu < lens; ++i) { int cnt = 0; for (i...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using std::cin; using std::cout; using std::endl; using std::ifstream; using std::ofstream; using std::string; using std::vector; int get_diff(const string::const_iterator begin1, const string::const_iterator end1, const string::const_iterator begin2) { string::const...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-15, PI = acos(-1); const int MOD = int(1e9) + 7, MX = int(1e5) + 1; const int N = 2010; int memo[N][N]; string a, b; int ED() { int n = int(a.size()), m = int(b.size()); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) if (a[i - ...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> const int MAXN = 2100; char s[MAXN], u[MAXN]; int forward[MAXN][MAXN], backward[MAXN][MAXN]; void update(int &a, int b) { if (b < a) a = b; } int main() { scanf("%s%s", s, u); int n = strlen(s), m = strlen(u); for (int i = 0; i <= m; i++) { backward[0][i] = i; } for (int i = m +...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.util.Scanner; public class qweqwe { public static void main(String args[]) { Scanner scan=new Scanner(System.in); String eg="................................."; while(eg.length()<=2000) { eg+="..................................................."; } String a=scan.next(); eg+=a; while...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> int max(int a, int b) { return (a > b ? a : b); } int min(int a, int b) { return (b > a ? a : b); } int main(void) { char str1[2001], str2[2001]; int i, j, len1, len2; int res, ans; scanf("%s", str1); scanf("%s", str2); len1 = strlen(str1); len2 = strlen(str2); res = 1000000; ...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; inline void normal(long long& a) { a = (a + 1000000007) % 1000000007; } inline long long modMul(long long a, long long b) { a %= 1000000007, b %= 1000000007; normal(a), normal(b); return (a * b) % 1000000007; } inline long long modAdd(long long a, long long b) { a %...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; import java.util.StringTokenizer; public class code { static class FastReader { BufferedReader br; StringTokenizer st; public Fas...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; template <class T> inline T MIN(T a, T b) { return a < b ? a : b; } template <class T> inline T GCD(T a, T b) { return b == 0 ? a : GCD(b, a % b); } const double pi = acos(-1.0); const double eps = 1e-10; const int inf = 0x3fffffff; int main() { string s, u; cin >> ...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> const int INF = 0x7fffffff; const double inf = 1e8; const double eps = 1e-10; const double PI = acos(-1.0); const int Max = 3001; char p[Max], q[Max]; using namespace std; int main() { int l, n, i, j; cin >> p >> q; l = strlen(p); n = strlen(q); int m = 0; for (i = -n + 1; i < l; i+...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; int main() { string s, u; cin >> s >> u; int n = s.length(); int m = u.length(); int b = 0; for (int i = 0; i < n; i++) { int c = 0; for (int j = 0; j < min(m, n - i); j++) { if (u[j] == s[i + j]) c++; } b = max(b, c); } for (int i = 0;...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; int main() { char s[6200]; char t[2010]; memset(s, '1', sizeof(s)); scanf("%s %s", s + 2000, t); int slen = strlen(s); int tlen = strlen(t); int mn = 2500; for (int i = 0; i < slen; i++) { int cnt = 0; for (int j = 0; j < tlen; j++) { if (s[i +...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.io.*; import java.awt.geom.Point2D; import java.text.*; import java.math.*; import java.util.*; public class Main implements Runnable { final String filename = ""; public void solve() throws Exception { String s = readword(); String t = readword(); int ans = s.length() + t.length(); int m =...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; int main() { char s[2003], u[2003]; while (cin >> s >> u) { int n = strlen(s); int m = strlen(u); int num = 0, ma = 0; for (int i = 0; i < n; i++) { num = 0; for (int j = i, k = 0; j < n && k < m; j++, k++) { if (s[j] == u[k]) num++; ...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; public class CF110A { private void work() throws IOException { Scanner sc = new Scanner(new BufferedReader(new InputStreamReader( System.in))); while (sc.hasNext()) { String s = sc.next()...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; const int maxx = 2000 + 10; char str1[maxx]; char str2[maxx]; int main() { while (cin >> str1 >> str2) { int k1 = strlen(str1); int k2 = strlen(str2); int judge; int kmax = -10000; for (int i = 0; i < k1; i++) { judge = 0; int pi = i; ...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); string a, b; cin >> a >> b; int m = b.size(); a = string(m, '.') + a + string(m, '.'); int n = a.size(); int ans = n + m; for (int i = 0; i + m <= n; ++i) { int dif = 0; for (int j = 0; j < m; +...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.ut...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.HashMap; import java.util.StringTokenizer; public class M...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import sys import traceback def solve(): src = sys.stdin.readline().strip('\n\r ') dst = sys.stdin.readline().strip('\n\r ') d = { } srclen = len(src) dstlen = len(dst) for i in range(srclen): if src[i] in d: d[src[i]] += [i] else : d[src[i]] = [i] matches = [0] * (srclen + dstlen) ...
PYTHON
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStreamReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; publ...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; int dn[2010][2010]; int res; char st1[2010], st2[2010]; int main() { scanf(" %s %s", st1 + 1, st2 + 1); for (int i = 1, mi = strlen(st1 + 1); i <= mi; i++) for (int j = 1, mj = strlen(st2 + 1); j <= mj; j++) { dn[i][j] = dn[i - 1][j - 1] + (st1[i] == st2[j]); ...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; char s1[2010], s2[2010]; int l1, l2; int calc(int k) { int ret = 0; for (int i2 = 0, i1 = k; i2 < l2; i2++, i1++) if (i1 >= 0 && i1 < l1 && i2 >= 0 && i2 < l2) ret += (s1[i1] != s2[i2]); else ret++; return ret; } int main() { scanf("%s%s", s1, s2...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; const int maxn = 1e3 + 300; const int INF = 0x3f3f3f3f; char s1[maxn * 2], s2[maxn * 2]; int dp[maxn * 2][maxn * 2]; int main() { scanf("%s%s", s1 + 1, s2 + 1); int len1, len2; len1 = strlen(s1 + 1); len2 = strlen(s2 + 1); int ans = 0; for (int i = 1; i <= len1;...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; const int INFI = (1 << 30); const long long INFL = (1LL << 62); int main() { char a[9000], b[2010], ax[2010]; for (int i = 0; i < 8000; i++) a[i] = 1; cin >> ax >> b; int n, m; m = strlen(ax); n = strlen(b); for (int i = 0; i < m; i++) a[i + 2000] = ax[i]; a...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.awt.Point; import java.io.*; import java.math.BigInteger; import java.util.*; import static java.lang.Math.*; public class A implements Runnable{ final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader in; PrintWriter out; StringTokenizer tok = n...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; long long MAXi(long long a, long long b) { return a > b ? a : b; } long long MINi(long long a, long long b) { return a < b ? a : b; } int main() { string a, b; int ans = 1000 * 1000, x; cin >> a >> b; a = string(2001, '^') + a + string(2001, '^'); for (int i = 0; ...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.util.*; import java.math.*; public class codeforces { static int dp[][]; public static void main(String[] args) { Scanner sc=new Scanner(System.in); String s=sc.next(); String u=sc.next(); int len=u.length(); ...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; int main() { string t1, t2; cin >> t1 >> t2; string tmp; for (int i = 0; i < 2000; ++i) tmp += " "; t1 = tmp + t1 + tmp; int mx = 0; for (int i = 0; i + t2.size() <= t1.size(); ++i) { int cnt = 0; for (int j = 0; j < t2.size(); ++j) cnt += (t2[j] == t1...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; template <typename T, typename S> ostream &operator<<(ostream &os, const pair<T, S> &p) { return os << "(" << p.first << ", " << p.second << ")"; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "["; for (int i = 0; i < (int)v.size(...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); cerr.writ...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; int i, j, l, l1; char s[2005], s1[2005]; int main() { scanf("%s", s); scanf("%s", s1); l = strlen(s); l1 = strlen(s1); int ans = 10000; for (i = -l1; i < l; i++) { int dif = 0; for (j = 0; j < l1; j++) { if (i + j >= l || i + j < 0) dif++; ...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import static java.lang.Math.*; import java.util.*; import java.io.*; public class A { public void solve() throws Exception { String s = nextLine(), t = nextLine(); int best = t.length(); for (int i=0; i<s.length()+t.length()-1; ++i) { int tmp = 0, cnt = 0, idx = max(0...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long double pi = acos(-1); int dp[2010][2010]; int custo[2010][2010]; int main() { string p, t; cin >> p >> t; memset(dp, 0, sizeof(dp)); memset(custo, 0, sizeof(custo)); int n = p.size(); int m = t.size(); for (int i = 0; i <...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Iterator; /** * @author : Petr * @date : 03.03.12 */ public class _156A { public static void main(String[] args) throws IOException { VKCupReader reader = new VKCupR...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.util.Scanner; public class CF_157C { public static void main(String[] args) { Scanner in = new Scanner(System.in); String orig = in.next(); String targ = in.next(); StringBuilder builder = new StringBuilder(); for(int i = 0; i < targ.length(); i++) { builder.append("*"); } orig = ...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; public class Main { public static void main(String[] args) { try { Parserdoubt pd=new Parserdoubt(System.in); PrintWriter pw=new PrintWriter(System.out); StringBuffer a=new StringBuf...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const long long INF = 1000 * 1000 * 1000 + 7; const long long LINF = INF * (long long)INF; const int MAX = 1000 * 100 + 47; string s; string t; string tmp; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> s >> t; for (int i ...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.util.Scanner; /** * @author irina orlova * Date: 09.05.12 - 21:11 */ public class Communication { public final static String CHARACTERS; static { String string = new String(); for (int i = 0; i < 2000; i++) { string += "@"; } CHARACTERS = string; ...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
s, u = input(), input() t = [0] * len(s) p = {i: [] for i in 'abcdefghijklmnopqrstuvwxyz'} for i, j in enumerate(s): p[j].append(i) for j in u: for i in p[j]: t[i] += 1 t = [0] + t print(len(u) - max(t))
PYTHON3
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; const int maxn = 2005; char s[maxn], d[maxn]; int main() { ios::sync_with_stdio(false); scanf("%s %s", s, d); int slen = strlen(s); int dlen = strlen(d); int i, j, k; int ans, tmp, m; ans = dlen; m = INT_MIN; for (i = 0; i < slen; ++i) { tmp = 0; f...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; int main() { string a, b; cin >> a >> b; long long mx = 0, n = a.size(), m = b.size(); for (int i = m - 1; i >= 0; i--) { int cnt = 0; for (int j = 0; j < n && i + j < m; j++) if (a[j] == b[i + j]) cnt++; if (cnt > mx) mx = cnt; } for (int i = ...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.util.*; import java.io.*; import java.math.*; public class Main2 { public static void main(String[] args) throws Exception { LR in = new LR(); char[] l1 = in.nx().toCharArray(); char[] l2 = in.nx().toCharArray(); int max = Integer.MIN_VALUE; for (int i =0;i<l1.le...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; string s, t; int main() { cin >> s >> t; int ns = s.size(); int nt = t.size(); int ans = nt; int i, j; for (i = -nt; i < ns; i++) { int now = nt; for (j = 0; j < nt; j++) { if (i + j >= 0 && i + j < ns && s[i + j] == t[j]) { now--; } ...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; void solveA() { string s, u; cin >> s >> u; string add; for (int i = 0; i < u.size(); ++i) add += '#'; string str = add; str.append(s); str.append(add); int res = -1; for (int i = 0; i + u.size() - 1 < str.size(); ++i) { int cnt = 0; for (int j = 0...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; string s, u; int main() { cin >> s >> u; int k = s.length(); int l = u.length(); int mini = l; for (int i = -l + 1; i < k; i++) { int cur = 0; for (int j = 0; j < l; j++) { if (i + j < 0 || i + j >= k) cur++; else cur += (s[i + ...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; public class Solution { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); ...
JAVA
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; const int maxN = 2000 + 100; const double pi = (double)(3.14159265); int a[maxN][maxN], row[maxN], col[maxN]; double s(int x) { return pi * x * x; } int n; int r[maxN]; int main() { string s, t_s, u; cin >> t_s >> u; s = ""; for (int i = 0; i < maxN; ++i) s += "0"; ...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC target("sse4") using namespace std; template <class c> struct rge { c b, e; }; template <class c> rge<c> range(c i, c j) { return rge<c>{i, j}; } template <class c> auto dud(c* x) -> decltype(cerr << *x, 0); template <class c> char dud(...); struct deb...
CPP
156_A. Message
Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba". Dr. Moriarty plans to take string s and cut out som...
2
7
#include <bits/stdc++.h> using namespace std; const int INF = 1000000; int main() { string str_1, str_2; cin >> str_1; cin >> str_2; int mas[str_1.length() + (str_2.length() - 1) * 2]; for (int i = 0; i < str_2.length(); ++i) { mas[i] = -1; } for (int i = 0; i < str_1.length(); ++i) { mas[str_2.le...
CPP