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 |
|---|---|---|---|---|---|
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
#pragma GCC optimize("-O2")
using namespace std;
const int N = 2e5 + 5, MOD = 1e9 + 7;
const long double EPS = 1e-9;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
string s, t;
long long cnt = 0, i, fs[26] = {}, ft[26] = {};
cin >> s >> t;
for (int i = 0; i < ... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
string s, t;
cin >> s >> t;
map<char, long long> cnt, mp, owe;
for (auto i : s) cnt[i]++;
for (auto i : t) mp[i]++;
long long lo = 0, hi = s.size(), mid, ans = 0;
while (lo <= hi) {
mid = (lo + hi) / 2;... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | import java.io.*;
import java.util.*;
public class Course {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String s = in.readLine(), t = in.readLine();
char[] ss = s.toCharArray();
int[] freq = n... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long inf = 2147483647;
const long long ll = 9223372036854775807, ninf = 1000000000;
const double eps = 1e-6;
const long long nll = 1000000000000000000;
map<char, int> num;
int main() {
string a;
while (cin >> a) {
string b;
cin >> b;
for (int i = 0; i <... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | import java.io.*;
import java.util.*;
public class Codeforces825D {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
String[] sp = br.readLine().split(" ");
String s = sp[0];
s... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class D {
static int n, m, q;
static char[] s, t;
static int[] sOcc, tOcc;
public static void main(String[] args) throws ... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
inline void write(long long a) {
if (a >= 10) write(a / 10);
putchar('0' + a % 10);
}
inline void writeln(long long a) {
write(a);
puts("");
}
inline long long read() {
long long x = 0;
char ch = getchar();
bool positive = 1;
for (; !isdigit(ch); ch = getcha... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | import sys
from collections import Counter
s = list(sys.stdin.buffer.readline().decode('utf-8').rstrip())
s_cnt = Counter(s)
t_cnt = Counter(sys.stdin.buffer.readline().decode('utf-8').rstrip())
ok, ng = 0, 10**6+1
hatena = s_cnt['?']
while abs(ok - ng) > 1:
mid = (ok + ng) >> 1
req = 0
for k, v in t_cnt... | PYTHON3 |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | import java.util.*;
import java.io.*;
public class B{
public static void main(String[] args)
{
FastScanner fs = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
String str = fs.next();
char[] str1 = new char[str.length()];
char[] str2 = fs.next().toCharArray();
long have = 0;
int[] coun... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | f = lambda q: ord(q) - 97
s, t = list(input()), input()
n, k = len(t), [0] * 26
for q in s:
if q != '?': k[f(q)] += 1
i = j = 0
while i < len(s):
if s[i] == '?':
while k[f(t[j % n])]:
k[f(t[j % n])] -= 1
j += 1
s[i] = t[j % n]
j += 1
i += 1
print(''.join(s)) | PYTHON3 |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int inf_int = 1e8;
long long inf_ll = 1e17;
const double pi = 3.1415926535898;
const long long mod = 1e9 + 7;
const int MAXN = 3e4 + 100;
bool debug = 1;
string s, t;
int cnt1[26], cnt2[26];
int has = 0;
bool ok(int val) {
long long need = 0;
for (int i = 0; i < 26; ++i... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int cnt[30];
int main() {
string s, t;
cin >> s >> t;
for (int i = 0; i < s.size(); i++) {
if (s[i] != '?') cnt[s[i] - 'a']++;
}
int tmp = 0;
int len = t.size();
for (int i = 0; i < s.size(); i++) {
if (s[i] == '?') {
tmp++;
tmp %= len;
... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | import java.io.*;
import java.math.*;
import java.nio.file.attribute.AclEntry.Builder;
import java.security.KeyStore.Entry;
import java.util.*;
public class CODEFORCES {
private InputStream is;
private PrintWriter out;
int time = 0, dp[][], DP[], start[], end[], dist[], black[], MOD = (int)(1e9+7), arr... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | import java.util.*;
import java.io.*;
public class A
{
public static void main(String ar[]) throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
char c[]=br.readLine().toCharArray();
char d[]=br.readLine().toCharArray();
... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long int a[200001];
void solve() {
long long int n, k, i, j, l, m, q = 0;
string second, t;
cin >> second;
cin >> t;
n = second.length();
m = t.length();
vector<long long int> fa(26), fb(26);
vector<long long int> pos;
for (i = 0; i < n; i++) {
if... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 |
import java.util.*;
import java.io.*;
/**
*
* @author usquare
*
*/
public class ProblemA {
static int mod = (int) (1e9+7);
static InputReader in;
static PrintWriter out;
public static void main(String[] args) throws FileNotFoundException {
in = new InputReader(System.in);
... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int cnt[26];
int cnt2[26];
int done[26];
int main(void) {
string s, t;
vector<int> pos;
cin >> s >> t;
int pp = 0;
for (auto c : s) {
if (c != '?')
cnt[c - 'a']++;
else if (c == '?')
pos.push_back(pp);
pp++;
}
for (auto c : t) cnt2[c - ... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | import java.io.*;
import java.util.*;
public class E {
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
char[] in = br.readLine().toCharArray();
char[] pat = br.readLine().toCharArray();
int a = 1;
char[] out = solve(in, pat,... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | import java.io.*;
import java.util.*;
public class E { // CodeForces 825D - Suitable Replacement
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
char[] in = br.readLine().toCharArray();
char[] pat = br.readLine().toCharArray();
... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 233;
char s[maxn], t[maxn];
int a[30], b[30];
bool check(int x) {
long long tot = 0;
for (int i = 1; i <= 26; i++) tot += max(0LL, 1LL * b[i] * x - a[i]);
if (tot > a[0]) return 0;
return 1;
}
int main() {
scanf("%s", s);
int n = strlen(s)... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = mod * mod;
const long double eps = 1e-12;
const long double pi = acos(-1.0);
long long mod_pow(long long a, long long n, long long m = mod) {
long long res = 1;
while (n) {
if (n & 1) res = res * a % m;
a =... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
string t;
cin >> t;
int sv[26] = {}, sv2[26] = {};
int cnt = 0;
for (int i = 0; i < s.size(); i++) {
if (isalpha(s[i]))
sv[s[i] - 'a']++;
else
cnt++;
}
for (auto c : t) sv2[c - 'a']++;
auto chk = [sv, ... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class A {
public static void main(... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 'z' - 'a' + 1;
int need[MAXN], have[MAXN], put[MAXN], ready[MAXN], is[MAXN];
vector<int> inte;
int main() {
char t[1000001], s[1000001];
int c = 0;
scanf("%s%s", s, t);
int lt = strlen(t), ls = strlen(s);
for (int i = 0; i < lt; i++) {
need[t[... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long double pi = 3.1415926535897932385;
const long double E = 2.71828182845904523536;
const double eps = 1e-9;
const long long mod = 1e9 + 7;
const long long inf = 1 << 30;
const int N = 1000010;
char s[N], t[N];
long long frq1[555], frq2[555];
bool vis[555];
vector<p... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 |
import static java.lang.System.out;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
/*
* 825D
* Any two letters can be swapped positions, these operations can be performed
* arbitrary number of times over any pair of positions. Among all resulting strings s,
... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int a[26], b[26];
long long int q;
int comp(long long int k) {
long long int qs = q;
for (int i = 0; i < 26; i++) qs -= max(b[i] * k - a[i], 0LL);
return qs >= 0;
}
int main() {
cin.tie(0);
cin.sync_with_stdio(0);
cout.precision(10);
string s, t;
cin >> s;
... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 |
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class SuitableReplacement {
public static void mai... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
int const maxn = 3000005;
string st[maxn];
int ab[200], ac[200], ad[200];
char b[maxn], c[maxn], d[maxn];
int main() {
cin >> b >> c;
int lenc = strlen(c);
for (int i = 0; i < lenc; i++) {
ac[c[i] - 'a']++;
... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int a[30];
stack<char> dit;
int main() {
string s1, s2;
cin >> s1 >> s2;
int sum = 0, len = s1.size();
for (int i = 0; i < len; i++) {
if (s1[i] == '?')
sum++;
else
a[int(s1[i] - 'a')]++;
}
len = s2.size();
while (sum > 0)
for (int i = ... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | //package cf.edu25;
import java.util.*;
public class D {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s = in.nextLine();
String t = in.nextLine();
Map<Character, Integer> existing = new HashMap<>();
for (char ch : s.toCharArray())
... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int n, cnt[100];
char s[1000010], t[1000010];
queue<char> q;
int main() {
int i;
scanf("%s %s", s, t);
n = strlen(t);
for (i = 0; s[i]; ++i) {
if (s[i] == '?')
++cnt[27];
else
++cnt[s[i] - 'a'];
}
for (i = 0; cnt[27]; i = (i + 1) % n) {
i... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
/**
*
*/
/**
* @author 7Alex
*
*/
public class SuitableReplacement {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedR... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
long long max(long long a, long long b) { return a > b ? a : b; }
long long min(long long a, long long b) { return a < b ? a : b; }
using namespace std;
const int maxn = 1e6 + 5;
char p[maxn], q[maxn];
int P[27], Q[27], V[27], R[27], F[27];
vector<int> v;
int main() {
int ans = 0;
memset(V,... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
using namespace std;
void file() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main() {
file();
string s1, s2;
cin >> s1 >> s2;
map<char, int> mp1, mp2;
for (auto e : s1) mp1[e]++;
for (auto e : s2) mp2[e]++;... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
const double pi = acos(-1.0);
const double eps = 1e-12;
using namespace std;
const int N = 26;
int cnts[N], cntt[N];
string s, t;
void solve() {
cin >> s >> t;
int n = s.size();
int m = t.size();
for (int i = 0; i < s.size(); i++) {
if (s[i] != '?') {
cnts[s[i] - 'a']++;
}... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | s,t = raw_input(), raw_input()
freqf = [0 for __ in xrange(26)]
for c in t:
freqf[ord(c) - ord('a')] += 1
freqs = [0 for __ in xrange(26)]
nq = 0
for c in s:
if c == '?':
nq += 1
else:
freqs[ord(c) - ord('a')] += 1
lo = 0
hi = 1000000
while lo < hi:
mid = (lo+hi+1) / 2
need = 0
for x in range(26):
need +... | PYTHON |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 |
import java.io.*;
import static java.lang.Double.max;
import static java.lang.Math.pow;
import java.util.*;
public class Kaudo {
static int ans,k,max=9999999;
static StringBuilder Sd=new StringBuilder();
static FastReader in=new FastReader();
public static void main(String[] args) {
char []S=in.next().toCha... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
char s[1000005];
char t[1000005];
int have[30];
int need[30];
int main() {
scanf("%s", s);
scanf("%s", t);
int lens = strlen(s);
int lent = strlen(t);
int cnt = 0;
for (int i = 0; i < lens; i++) {
if (s[i] != '?') have[s[i] - 'a']++;
}
for (int i = 0; i ... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | s=raw_input()
t=raw_input()
a=[0 for i in xrange(28)]
b=[0 for i in xrange(28)]
cnt=0
for c in s:
if c=="?":
cnt+=1
else:
a[ord(c)-97]+=1
for c in t:
b[ord(c)-97]+=1
def calc(num):
cnum=0
for i in range(26):
cnum+=max(num*b[i]-a[i],0)
return cnum
l=0
r=1000005
p=-1
while ... | PYTHON |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:667772160")
template <class T1>
void deb(T1 e1) {
cout << e1 << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
cout << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
co... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | from collections import Counter
s, t = input(), input()
cs, ct = Counter(s), Counter(t)
# print(ct, cs)
remain = Counter()
# print(cs - ct)
while True:
for x in ct:
if cs[x] < ct[x]:
plus = ct[x] - cs[x]
if cs['?'] < plus:
# print(remain)
cl = []
... | PYTHON3 |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Vector;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.Stack;
impo... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
bool possible(std::vector<int> &s, std::vector<int> &d) {}
int main() {
int64_t r, k;
std::string s, d;
std::cin >> s >> d;
std::vector<int> S(27, 0), D(26, 0), Add(26, 0);
for (int i = 0; i < s.size(); i++) {
if (s[i] != '?') {
S[s[i] - 'a']++;
} else {
S[26]++;
... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | s = input()
t = input()
count_q = s.count('?')
set_t = set(t)
c_s = {i: s.count(i) for i in set_t}
c_s['?'] = s.count('?')
c_t = {i: t.count(i) for i in set_t}
max_n = sum(c_s.values()) // sum(c_t.values())
for i in set_t:
c_s[i] -= (c_t[i] * max_n)
while True:
ss = c_s['?']
for i in c_s.values():
... | PYTHON3 |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
string s, t;
int cnts[26], cntt[26];
vector<int> ids;
int sl, tl, q, id;
bool can(int x) {
int tmp = 0;
for (int i = 0; i < 26; i++) tmp += max(0, cntt[i] * x - cnts[i]);
return tmp <= q;
}
int main() {
cin >> s >> t;
for (auto c : s) {
if (c == '?')
q++... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ',');
cerr.write(nam... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
char s[1000000 + 10], t[1000000 + 10], wen[1000000 + 10];
int tcnt[30], scnt[30], temp[30];
int wencnt;
int main() {
scanf("%s", s);
scanf("%s", t);
int lens, lent;
lens = strlen(s);
lent = strlen(t);
for (int i = 0; i < lens; i++) {
if (s[i] == '?')
w... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
string s, t;
vector<long long> res;
long long cntt[27];
long long cnts[27];
long long cans;
int main() {
cin.sync_with_stdio(0);
cin.tie(0);
cin >> s >> t;
for (long long i = 0; i <= (long long)t.length() - 1; ++i) {
++cntt[t[i] - 'a' + 1];
}
for (long long ... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | def check(mid,ha,has,c):
need=0
for i in range(26):
need+=max(0,ha[i]*mid-has[i])
# print(mid,need)
return c>=need
ss='abcdefghijklmnopqrstuvwxyz'
s = list(input())
t = list(input())
ha=[0]*26
has=[0]*26
m=10000000000
c=0
for i in t:
ha[ord(i)-ord('a')]+=1
for i in s:
if i=='?':
... | PYTHON3 |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
string s, t;
int q = 0;
int cnt[30];
int getNxt() {
for (int i = 0; i < 30; i++) {
if (cnt[i] != 0) {
cnt[i]--;
return i;
}
}
}
int getQ() {
for (int i = 0; i < 30; i++) {
if (cnt[i] >= 1) {
cnt[i]--;
return (i + 'a');
}
}
}
i... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | import sys
#import random
from bisect import bisect_left as lb
from collections import deque
#sys.setrecursionlimit(10**8)
from queue import PriorityQueue as pq
from math import *
input_ = lambda: sys.stdin.readline().strip("\r\n")
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda ... | PYTHON3 |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
void read(bool out = 0) {}
int main() {
string second;
string t;
cin >> second >> t;
if (second.length() < t.length()) {
for (int i = 0; i < second.length(); i++) {
if (second[i] == '?') second[i] = 'a';
}
cout << second << "\n";
return 0;
}
... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int len = 1e6 + 5;
char s[len], t[len];
int rem[30], word[30], fin[30];
int main() {
scanf("%s %s", &s, &t);
int n = strlen(s), m = strlen(t), cnt = 0;
for (int i = 0; i < n; i++) {
if (s[i] == '?')
cnt++;
else
rem[s[i] - 'a']++;
}
for (i... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
char s[1000002], t[1000002];
int number1[27], number2[27], cnt, vip, temp, len1, len2;
vector<char> ans;
scanf("%s", s + 1);
scanf("%s", t + 1);
len1 = strlen(s + 1);
len2 = strlen(t + 1);
vip = 0;
for (int i = 1; i <= len1; i++) {
if (s[i... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
template <class T>
inline bool MX(T &l, const T &r) {
return l < r ? l = r, 1 : 0;
}
template <class T>
inline bool MN(T &l, const T &r) {
return l > r ? l = r, 1 : 0;
}
signed main() {
ios_base::sync_with_stdio(false);
cout << fixed <... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | import java.io.*;
import java.util.*;
/**
* Created by Katushka on 11.03.2020.
*/
public class B {
static int[] readArray(int size, InputReader in) {
int[] a = new int[size];
for (int i = 0; i < size; i++) {
a[i] = in.nextInt();
}
return a;
}
static long[] re... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
mt19937 rnd(rand());
long long a[26], b[26];
string s, t;
long long n, m;
long long k = 0;
bool check(long long mid) {
long long ost = k;
long long nado[26];
for (long long i = 0; i < 26; ++i) {
nado[i] = a[i] * mid;
}
for (long long i = 0; i < 26; ++i) {
... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | //package code;
import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
public class A {
static Scanner scan;
void calc() {
scan = new Scanner(System.in);
String s = scan.next();
String t = scan.next();
int[] cs = new int [26];
... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
char s[1000100];
char t[1000100];
int main(void) {
scanf("%s", s);
scanf("%s", t);
int sl = strlen(s);
int tl = strlen(t);
vector<long long int> sf(26), tf(26);
long long int que = 0;
for (int i = (int)(0); i < (int)(sl); i++) {
if (s[i] == '?')
que ... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
public static void main(String args[]) throws IOException{
BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
String s1=reader.readLine();
String s2=reade... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
string a, b;
char ans[1000008];
int num[28], p, tot, len;
bool vis[28];
int main() {
cin >> a >> b;
len = a.size();
for (int i = 0; i < len; i++) {
if (a[i] != '?') {
num[a[i] - 'a']++;
}
}
for (int i = 0; i < b.size(); i++) {
vis[b[i] - 'a'] = 1... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int svalues[26];
int tvalues[26];
int resvalues[26];
int main(int argc, const char* argv[]) {
string s, t;
cin >> s >> t;
long long qs = 0;
string temp;
for (long long i = (0); i < (s.length()); i++) {
if (s[i] == '?')
qs++;
else
svalues[s[i] -... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const double eps = 1e-9;
map<char, long long> map1, map2, used;
int main() {
cin.sync_with_stdio(false);
string a, b;
while (cin >> a >> b) {
map1.clear();
map2.clear();
used.clear();
long long ans = 0;
long long cnt ... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | def main():
s = input()
t = input()
nd = {}
hv = {}
for x in t:
if x not in nd:
nd[x]=1
else:
nd[x]+=1
for x in s:
if x not in hv:
hv[x]=1
else:
hv[x]+=1
def f(n):
hp = 0
if("?" in hv):
... | PYTHON3 |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
map<char, int> ms;
map<char, int> mt;
string s, t;
char k[1123456];
int m, n;
int z = 0;
int mini = 1e7;
int counter = 0;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> s >> t;
m = s.size();
n = t.size();
for (int i = 0; i < m; i++) ms[s[i]]++;
... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | import java.util.HashSet;
import java.util.Scanner;
/**
* Created by Berry on 17-7-20.
*/
public class Binaryprotocol {
public static void main(String[] args){
Scanner stdin = new Scanner( System.in );
String s = stdin.next();
String t = stdin.next();
int[] arr = new int[100];
... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int a[30];
int b[30];
string s1, s2;
int len1;
int len2;
int cnt;
int Cnt;
bool check(int x) {
int re = 0;
memset(b, 0, sizeof(b));
for (int i = 0; i < len2; i++) {
b[s2[i] - 'a' + 1]++;
}
for (int i = 1; i <= 26; i++) {
if (!b[i]) {
continue;
}
... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | import java.io.*;
import java.lang.reflect.Array;
import java.math.*;
import java.security.KeyStore.Entry;
import java.util.*;
public class Main {
private InputStream is;
private PrintWriter out;
int time = 0, dp[][], DP[][], dist[], prime[], start[], parent[], end[],
val[], black[], arr[], arr1[][];
long MOD ... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
string s, t;
map<char, int> used, needed;
inline bool check() {
int mn = 2e9;
for (map<char, int>::iterator it = used.begin(); it != used.end(); it++) {
if (it->second < needed[it->first]) {
return false;
}
mn = min(mn, it->second / needed[it->first]);... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long MaxN = 3100002;
long long c;
string s, t;
long long hs[MaxN], ht[MaxN];
bool solve(long long k) {
long long sum = 0;
for (int i = 0; i < 26; i++) {
sum += ht[i] * k - min(hs[i], k * ht[i]);
}
if (sum <= c) return true;
return false;
}
int main(... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int mxN = 1e6 + 6;
char s[mxN], t[mxN];
int freq[29], freq2[29];
int main() {
scanf("%s %s", s + 1, t + 1);
int n = strlen(s + 1);
int m = strlen(t + 1);
for (int i = 1; i <= m; ++i) ++freq2[t[i] - 'a'];
int have = 0;
for (int i = 1; i <= n; ++i) {
if ... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | def solve(mid):
tmp = 0
for i in cnt_t:
if cnt_t[i] * mid <= cnt_s[i]:
pass
else:
tmp += cnt_t[i] * mid - cnt_s[i]
return tmp <= cnt_s["?"]
def solve2(mid):
tmp = deque([])
for i in cnt_t:
if cnt_t[i] * mid <= cnt_s[i]:
pass
else:
... | PYTHON3 |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | //package kattis.Codeforces;
import java.io.*;
import java.util.*;
public class D425 {
public static void main(String[] args) throws IOException {
IO io = new IO(System.in);
char[] s = io.next().toCharArray(), t = io.next().toCharArray();
int[] counts = new int[27];
for (int i = 0; i < s.length; i++) {
i... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws FileNotFoundException {
ConsoleIO io = new ConsoleIO(new InputStreamReader(System.in), new PrintWriter(System.out));
//String test = "C-small-attempt0";
//ConsoleIO io = new ConsoleIO(new... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | s = list(input())
t = input()
abc = 'abcdefghijklmnopqrstuvwxyz'
dabc ={}
for i in range(26):
dabc[abc[i]] = i
lt = {}
ls = {}
dd = {}
ls['?'] = 0
for i in abc:
lt[i] = 0
ls[i] = 0
dd[i] = 0
for letter in t:
lt[letter] += 1
for letter in s:
ls[letter] +=1
X = ls['?']
def check(ans):
global ls, lt, abc, X
retu... | PYTHON3 |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long a[26] = {0}, b[26] = {0};
int main() {
string s, t;
cin >> s >> t;
int i, l = 0;
for (i = 0; i < s.size(); i++)
if (s[i] != '?') a[s[i] - 'a']++;
for (i = 0; i < t.size(); i++) b[t[i] - 'a']++;
for (i = 0; i < s.size(); i++) {
if (s[i] == '?') ... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 |
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int[] int1 = new int[300];
int[] int2 = new int[300];
char[] s = new char[1000005];
char[] t = new char[1000005];
int counter = 0;
int max = -1000;
... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
string s, t;
cin >> s >> t;
long long n = s.length(), m = t.length(), i, cnt = 0, x = 0, j = 0;
long long trr[26] = {0};
long long srr[26] = {0};
for (i = 0; i < m; i++) {
trr[t[i] - 'a']++;
}
for (i = 0; i < n; i++) {
if (s[i] != '?')
... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int dp[2][30], add;
char s[1000005], t[1000005];
vector<char> v;
int main() {
scanf("%s %s", s + 1, t + 1);
int les = strlen(s + 1);
int let = strlen(t + 1);
for (int i = 1; i <= let; i++) {
dp[0][t[i] - 'a']++;
}
for (int i = 1; i <= les; i++) {
if (s[i... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
template <typename T, typename TT>
inline ostream &operator<<(ostream &os, const pair<T, TT> &t) {
return os << t.first << " " << t.second;
}
template <typename T>
inline ostream &operator<<(ostream &os, const vector<T> &t) {
for (auto i : ... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
char s[1000010], t[1000010];
int ss, ts, ar[26], br[26], c, q, p, mark[26];
int bs(int l, int r) {
if (l == r) return l;
if (r - l == 1) {
int a = 0;
for (int i = 0; i < 26; i++) a += br[i] * r - min(br[i] * r, ar[i]);
if (a <= q) return r;
return l;
}... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
string s, t;
long long nut[300] = {0};
long long nus[300] = {0};
long long ssr[300] = {0};
signed main() {
cin >> s;
cin >> t;
long long si = s.size();
long long ti = t.size();
for (long long i = 0; i < ti; i++) {
nut[t[i]]++;
}
for (long long i = 0; i < s... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
string a, b;
map<char, long long> mpa, mpb;
void Input() { cin >> a >> b; }
bool check(long long mid) {
long long c = mpa['?'];
for (auto it : mpb) {
long long d = mid * it.second - min(mid * it.second, mpa[it.first]);
if (d) {
... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 5;
map<char, int> mp, mpp, sk, dj;
set<pair<pair<int, int>, char> > st;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
string s, t;
cin >> s >> t;
int i;
for (i = 0; i < int(s.size(... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | //package Jul22;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
/**
* Created by kandarp.jo on 22/07/17.
*/
public class D {
public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
public static PrintWrit... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | # @oj: codeforces
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-11-18 19:10
# @url:https://codeforc.es/contest/825/problem/D
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio
BUFSIZE = 8192
BUFSIZE = 8192
class FastIO... | PYTHON3 |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;
/**
* @since 2017/7/22
*/
public class Main {
private static Scanner reader = new Scanner(System.in);
private static PrintStream writer = System.out;
private void a() {
int n = reader.nextInt();
reader.nextLi... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const long long INFll = 1ll * 1000000009 * 1000000009;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
string second, t;
cin >> second >> t;
vector<int> cnt1(26, 0), cnt2(26, 0);
int x = 0;
for (int i = 0; i < second.length(); i... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int arr[1234];
vector<int> vec;
int main() {
std::ios::sync_with_stdio(false);
string s, t, st;
cin >> s >> t;
st = s;
int n = s.length();
int m = t.length();
int i, j;
for (i = 0; i < s.length(); i++) {
arr[s[i]]++;
if (s[i] == '?') {
vec.push... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
string a, b;
cin >> a >> b;
map<char, long long int> da, db;
long long int q = 0;
for (char c : a) {
c == '?' ? q++ : da[c]++;
}
for (char c : b) {
db[c]++;
}
long ... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | s = input()
t = input()
abc = 'abcdefghijklmnopqrstuvwxyz'
dabc ={}
for i in range(26):
dabc[abc[i]] = i
lt = {}
ls = {}
dd = {}
ls['?'] = 0
for i in abc:
lt[i] = 0
ls[i] = 0
dd[i] = 0
for letter in t:
lt[letter] += 1
for letter in s:
ls[letter] +=1
X = ls['?']
def check(ans):
global ls, lt, abc, X
return -su... | PYTHON3 |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
string s, t;
int arr1[2222], arr2[2222];
char ans[999999];
long long int i, j, lo, hi, mid, cnt, sum, nd;
queue<int> q;
int main() {
cin >> s >> t;
for (i = 0; i < t.size(); i++) {
arr2[(int)(t[i] - 'a')]++;
}
cnt = 0;
for (i = 0; i < s.size(); i++) {
if (... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
char s[1000055], t[1000055];
int a[26], b[26];
int can;
int n;
inline bool trial(int x) {
long long need = 0ll;
for (int i = 0; i < 26; i++) {
long long u = a[i];
long long v = 1ll * b[i] * x;
need += max(0ll, v - u);
}
return need <= 1ll * can;
}
void c... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int a[30];
stack<char> dit;
int main() {
string s1, s2;
cin >> s1 >> s2;
int sum = 0, len = s1.size();
for (int i = 0; i < len; i++) {
if (s1[i] == '?')
sum++;
else
a[int(s1[i] - 'a')]++;
}
len = s2.size();
while (sum > 0)
for (int i = ... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
private static String s, t;
private static int questionMarkCount;
private static long charCountS[] = new long[200], charCountT[] = new long[200];
public static PrintWriter out;
publ... | JAVA |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
unsigned letter_frequency_t[26];
unsigned letter_frequency_s[26];
unsigned replacement_counts[26];
unsigned qcount;
int main(void) {
ios::sync_with_stdio(false);
cin.tie(0);
string s, t, s1;
cin >> s >> t;
s1 = s;
for (unsigned i = 0; i < s.length(); ++i) {
... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
string s, t;
cin >> s >> t;
int slc[26] = {0};
int tlc[26] = {0};
for (int i = 0; i < s.length(); i++) {
if (s[i] != '?') {
slc[s[i] - 'a'] += 1;
}
}
for (int i = 0; i < t.length(); i++) {
tlc[t[i] - 'a'] += 1;
}
string temp ... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
string s, t;
int used[3000], needed[3000];
inline bool check() {
int mn = 2e9;
for (char j = 'a'; j <= 'z'; j++) {
if (needed[j - 'a'] && used[j - 'a'] < needed[j - 'a']) {
return false;
}
if (needed[j - 'a']) mn = min(mn, used[j - 'a'] / needed[j - 'a... | CPP |
825_D. Suitable Replacement | You are given two strings s and t consisting of small Latin letters, string s can also contain '?' characters.
Suitability of string s is calculated by following metric:
Any two letters can be swapped positions, these operations can be performed arbitrary number of times over any pair of positions. Among all resulti... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
vector<char> ans;
int amm[30];
int main() {
string s, t;
cin >> s >> t;
int wild = 0;
for (int i = 0; i < s.size(); i++) {
if (s[i] == '?')
wild++;
else
amm[s[i] - 'a']++;
}
int curr = 0;
bool flag = true;
while (flag) {
for (int i = ... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.