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 | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Collections.*;
import static java.util.Arrays.*;
public class ProblemD {
static class Problem {
InputReader reader;
PrintWriter writer;
Problem() {
reader = 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(raw_input())
t = list(raw_input())
lets = 'abcdefghijklmnopqrstuvwxyz'
cnt = [0 for x in range(26)]
need = [0 for x in range(26)]
take = [0 for x in range(26)]
for i in s:
if i=='?':
continue
cnt[lets.find(i)]+=1
for i in t:
need[lets.find(i)]+=1
cur = s.count('?')
ans = 0
while True:
for i in rang... | 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;
const int maxn = 1e6 + 5;
int a[30], b[30];
queue<char> ans;
int main() {
ios::sync_with_stdio(false);
string s, t;
cin >> s >> t;
for (auto i : s) {
if (i == '?')
a[0]++;
else
a[i - 'a' + 1]++;
}
for (auto i : t) b[i - 'a' + 1]++;
while (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;
const int N = 1000010;
char s[N], t[N];
int main() {
scanf(" %s", s);
scanf(" %s", t);
int n = strlen(s);
int n2 = strlen(t);
int low = 1, high = n / n2, res = 0;
while (high >= low) {
int mid = (low + high) / 2;
int frq[26] = {0}, q = 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 | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 1000005;
char s[MAXN], t[MAXN];
int tch[26], sch[26], ns, nt;
int lch[26], tmp[26];
int main() {
scanf("%s", s);
ns = strlen(s);
scanf("%s", t);
nt = strlen(t);
int cntq = 0;
for (int i = (0); i < (nt); i++) tch[t[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>
std::string s, t;
int freq[256];
int to[256];
int main() {
std::cin >> s >> t;
for (auto a : s) freq[a]++;
int on = 0, pt = 0;
while (on != s.size()) {
char got = 0;
if (freq[t[on % t.size()]])
got = t[on % t.size()];
else if (freq['?'])
got = '?';
else {
... | 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;
template <class A>
void pr(A a) {
cout << a;
cout << '\n';
}
template <class A, class B>
void pr(A a, B b) {
cout << a << ' ';
pr(b);
}
template <class A, class B, class C>
void pr(A a, B b, C c) {
cout << a << ' ';
pr(b, c);
}
template <class A, class B, class ... | 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 s1, s2;
getline(cin, s1);
getline(cin, s2);
long long i, j, kol = 0, a[26] = {}, b[26] = {};
long long n = s1.length(), m = s2.length(), mix = 1, y;
for (i = 0; i < n; i++) {
if (s1[i] == '?')
kol++;
else
a[(s1[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;
vector<char> order;
int how_t[26], how_s[26], s_added[26];
int que = 0;
bool check(int l) {
int needed = 0;
for (int i = 0; i < 26; i++) {
if (how_t[i] * l > how_s[i]) {
needed += how_t[i] * l - how_s[i];
}
}
if (needed > que) {
return false;
}
... | 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);
int i, ct, r;
string s, t;
int ct_left[26], ct_req[26];
memset(ct_left, 0, sizeof(ct_left));
memset(ct_req, 0, sizeof(ct_req));
stack<char> ans;
cin >> s >> t;
ct = 0;
for (i = 0; i < s.leng... | 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.math.*;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
Task tt = 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 | import java.util.Scanner;
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;
public class TestClass //implements Runnable
{
int x,y,cost;
public TestClass(int x,int y,int cost)
{
this.x=x;
this.y=y;
this.cost=cost;
}
public static void main(Strin... | 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 mod = 1e9 + 7;
bool chk(vector<long long> &cntS, vector<long long> &cntT, long long qcnt,
long long mid) {
long long val = 0;
for (long long i = 0; i < 26; i++) {
val = val + mid * cntT[i] - min(cntT[i] * mid, cntS[i]);
}
return val <= qcnt;
}
int m... | 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 defaultdict
s, t = raw_input(), raw_input()
dt = defaultdict(int)
for ch in t:
dt[ch] += 1
ds = defaultdict(int)
for ch in s:
ds[ch] += 1
ch_to_question_mark = defaultdict(int)
while True:
is_complete = True
tmp = ds.copy()
tmp_ch = defaultdict(int)
for ch, count in dt... | 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;
const int limit = 1e6;
char s[limit + 5], t[limit + 5];
inline void init() {
gets(s);
gets(t);
}
int ca = 0;
int cs[27], ct[27];
bool check(int mid) {
long long c = 0;
for (int i = 0; i < 26 && c <= ca; i++)
c += (cs[i] >= ct[i] * 1LL * mid) ? (0) : (ct[i] * 1LL... | 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, ans;
int c = 0, rc, tn, cn;
cin >> s >> t;
int sa[26] = {0}, ta[26] = {0}, qn = 0;
int i, j, k;
for (i = 0; i < s.length(); i++) {
if (s[i] == '?')
qn++;
else
sa[s[i] - 97]++;
}
for (i = 0; i < t.length(); i++) 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;
char s[1000004], t[1000005];
int ss[30] = {0}, ts[30] = {0};
int ans = 0;
bool ju(int n) {
int cnt = 0;
for (int i = 0; i < 26; i++) {
if (ts[i] * n > ss[i]) cnt += ts[i] * n - ss[i];
}
if (cnt <= ans) return true;
return false;
}
char out[1000005];
void outpu... | 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;
void tData(string& t, vector<int>& v) {
for (int i = 0; i < (t.size()); ++i) {
if (t[i] != '?')
v[t[i] - 'a']++;
else
v[26]++;
}
}
queue<char> q;
bool fill(vector<int>& t, vector<int>& p) {
for (int i = 0; i < (t.size() - 1); ++i) {
if (t[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_base::sync_with_stdio(false);
string a;
cin >> a;
string b;
cin >> b;
long long question_mark = 0;
vector<long long> q;
vector<long long>::iterator it;
long long has[26] = {0};
for (long long i = 0; i < a.size(); i++) {
if (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 | #include <bits/stdc++.h>
using namespace std;
char s1[1000010], s2[1000010];
int a[27], b[27];
int check() {
while (1) {
for (int i = 0; i < 26; i++)
if (a[i] < b[i]) return i;
for (int i = 0; i < 26; i++) a[i] -= b[i];
}
}
int main() {
scanf("%s%s", s1, s2);
int len2 = strlen(s2);
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 | #include <bits/stdc++.h>
using namespace std;
void rd(long long &x) { scanf("%lld", &x); }
void rd(long long &x, long long &y) { scanf("%lld%lld", &x, &y); }
void rd(long long &x, long long &y, long long &z) {
scanf("%lld%lld%lld", &x, &y, &z);
}
map<char, long long> ms, mt;
string s, t;
long long sl, tl, k;
bool ok(... | 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.io.PrintWriter;
import java.util.StringTokenizer;
public class P825D
{
public static void main(String[] args)
{
FastScanner scan = new FastScanner();
PrintWriter pw = new PrintWriter(System.out);
char[] 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.util.*;
import java.io.*;
public class Main {
public static void main (String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
char str[] = br.readLine().toCharArray();
char pat[] = br.readLine().toCharArray();
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 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U>
using Pa = pair<T, U>;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
string S, T;
cin >> S >> T;
int N = S.size(), M... | 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(false);
cin.tie(0);
string s, t;
cin >> s >> t;
int sCnt[26], tCnt[26];
memset(sCnt, 0, sizeof(sCnt));
memset(tCnt, 0, sizeof(tCnt));
for (int i = 0; i < 26; i++) {
sCnt[i] = count(s.begin(), s.end(), 'a' + i);
tCnt[... | 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.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class D {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
PrintWriter out =... | 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[1010101], t[1010101];
int cs[26], ct[26], q, cc[99];
int main() {
scanf("%s%s", s, t);
for (int i = 0; s[i]; i++)
if (s[i] == '?')
q++;
else
cs[s[i] - 'a']++;
for (int i = 0; t[i]; i++) ct[t[i] - 'a']++;
int bl = 0, br = 1010101, ba = 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 | import java.io.*;
import java.util.*;
import java.util.Map.Entry;
import java.lang.Math;
import java.math.BigInteger;
public class Problem {
class Powers2_5 {
int pow2, pow5;
Powers2_5(int pow2, int pow5) {
this.pow2 = pow2;
this.pow5 = pow5;
}
}
void solve() throws IOException {
char[] s = rS().toC... | 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 a[26], b[26];
bool check(long long x, long long k) {
long long s = 0;
for (long long i = 0; i < 26; i++) s += max(b[i] * x - a[i], 0ll);
return s <= k;
}
signed main() {
ios_base::sync_with_stdio(false), cin.tie(NULL);
string s, t;
cin >> s >> t;
lon... | 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 freqs[27], freqt[27], ein;
int check(long long k) {
long long cnt = 0;
for (int i = 0; i < 26; i++) {
long long dif = freqt[i] * k - freqs[i];
cnt += max(0LL, dif);
}
return cnt <= ein;
}
int leftmost(int left = 1, int right = 1000007)... | 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;
class InputReader {
public:
InputReader(std::istream& stream) { input = &stream; }
template <class T>
T read() {
T next;
*input >> next;
return next;
}
int readInt() { return this->read<int>(); }
private:
std::istream* input;
};
class OutputPrinte... | 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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Deque;
import java.util.ArrayDeque;
import java.io.InputStreamReader;
import java.io.InputStream;... | 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 INF = 1e16;
const int MX = 100015;
string s, t;
int kmp[1000005];
int T[1005];
vector<char> v;
int main() {
cin >> s >> t;
int p1 = 0, p2 = 1;
while (p2 < t.size()) {
if (t[p1] == t[p2]) {
kmp[p2] = p1 + 1;
p1++;
p2++;
conti... | 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 {
private FastScanner scanner = new FastScanner();
public static void main(String[] args) {
new Main().solve();
}
private void solve() {
String a = scann... | 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.lang.reflect.Array;
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
char[]s = sc.next().toCharArray();
char[]t = sc.ne... | 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 sun.reflect.generics.tree.Tree;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.plaf.synth.SynthTextAreaUI;
import java.io.*;
import java.net.Inet4Address;
import java.text.DecimalFormat;
import java.util.*;
import java.awt.Point;
public class Newbie {
static InputReader sc = new InputR... | 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 + 10;
map<char, int> mp1, mp2;
char s1[maxn], s2[maxn];
char ss[maxn];
int main() {
scanf("%s", s1);
int len1 = strlen(s1);
for (int i = 0; i < len1; i++) mp1[s1[i]]++;
scanf("%s", s2);
int len2 = strlen(s2);
for (int i = 0; i < len2; i++) m... | 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 maxn = 1e6 + 100;
char str[maxn];
char abc[maxn];
int bq[30];
struct node {
int snum, tnum;
char s;
} data[30];
bool check(long long mid, long long op) {
long long temp = 0;
for (int i = 0; i < 26; i++) {
if (data[i].tnum != 0) {
long long thi = ... | 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 Problems1{
public static void main(String[] args) throws IOException {
FastScanner sc=new FastScanner(System.in);
String have=sc.next();
String req=sc.next();
int h[]=new int[26];
int r[]=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;
int ns[26], nt[26];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
string s, t, ans;
cin >> s >> t;
int add = 0;
for (int i = 0; i < s.length(); i++) {
if (s[i] == '?')
add++;
else
ns[s[i] - 'a']++;
}
for (int i = 0; i < t.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.util.*;
public class Rough {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
//code goes here
char arr[] = sc.next().toCharArray();
char brr[] = sc.next().toCharArray();
int cnt[] = new int[26];
int sub[]=... | 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];
vector<long long int> fa(26), fb(26);
vector<long long int> pos;
bool isitpossible(long long int mid, long long int q) {
for (int i = 0; i < 26; i++) {
long long int req = fb[i] * mid;
q -= max(0LL, req - fa[i]);
}
return q >= 0;
}
voi... | 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 M = 1e6 + 10;
char s[M], t[M];
int a[26], b[26];
int main() {
scanf("%s%s", s, t);
int cnt = 0;
for (int i = 0; s[i]; i++) {
if (s[i] == '?')
cnt++;
else
a[s[i] - 'a']++;
}
for (int i = 0; t[i]; i++) {
b[t[i] - 'a']++;
}
int 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>
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];
char v[maxn];
int P[27], Q[27];
int main() {
scanf("%s", p);
scanf("%s", q);
memset(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 java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Scanner;
public class D {
private static final String REGEX = " ";
private static final Boolean DEBUG = false;
private static final String FILE_NAME = "input.txt";
public static ... | 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.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;
public class Contest {
private static int sNext;
private static final int EOF = -1;
private static InputStream sIn = System.in;
private static... | 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 + 5;
char s[maxn];
char t[maxn];
int mark = 0;
int ss[30], tt[30];
int sneed[30];
int main() {
memset(ss, 0, sizeof(ss));
memset(tt, 0, sizeof(tt));
memset(sneed, 0, sizeof(sneed));
cin >> s;
cin >> t;
int n = strlen(s);
int m = strlen(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 int MAXN = 1e6 + 10;
int n, m;
char s[MAXN], t[MAXN];
int tongs[150], tongt[150];
int cntp;
inline bool chk(int mid) {
long long sum = 0;
for (int i = 'a'; i <= 'z'; i++)
sum += max(0ll, (long long)tongt[i] * mid - tongs[i]);
return sum <= cntp;
}
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 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main{
public static void main(String args[]) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String 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;
const int maxn = 1e6 + 10;
char a[maxn], b[maxn];
int ned[35], have[35];
int main() {
scanf("%s%s", a, b);
int lena = strlen(a), lenb = strlen(b);
for (int i = 0; i < lenb; i++) ned[b[i] - 'a']++;
int fuck = 0;
for (int i = 0; i < lena; i++) {
if (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 | from sys import stdin, stdout
EPS = 10 ** (-20)
INF = float('inf')
sze = 26
first = list(stdin.readline().strip())
second = list(stdin.readline().strip())
symbols1 = [0 for i in range(sze)]
for f in second:
symbols1[ord(f) - 97] += 1
symbols2 = [0 for i in range(sze + 1)]
for f in first:
if f == '?':
... | 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;
template <typename T>
using vc = vector<T>;
template <typename T, typename X>
using pr = pair<T, X>;
const long long int MOD = 1e9 + 7;
const long double PI = 3.14159265;
long long int powerWithMod(long long int base, long long int exponent,
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 | #include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
if (a == 0) return b;
return gcd(b % a, a);
}
long long int arr[100001];
long long int summer(int n, int k) {
long long int maxsum = 0;
long long int b[n + 1];
for (int i = 1; i <= n; ++i) {
b[i] = arr[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;
queue<char> q;
map<char, int> cnt;
int main() {
ios_base::sync_with_stdio(0);
string s;
string t;
cin >> s;
cin >> t;
int k = 0;
for (int i = 0; i < s.size(); i++) {
if (s[i] == '?')
k++;
else
cnt[s[i]]++;
}
int j = 0;
while (k > 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 | import java.util.*;
public class B {
static String s, t;
static long what = 0;
static long[] ar = new long[2000006];
static long[] ar2 = new long[2000006];
public static boolean rec(long mid, long vv) {
for (long i = 0; i < 26; i++) {
long m = ar[(int) i];
long mm = ar2[(int) i] * mid;
if (mm > m) {
... | 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.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;
public class D_Edu_Round_25 {
public static void main(String[] args) t... | 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[27][2], x;
void go() {
while (x < 26 && cnt[x][0] >= 0) x++;
if (x == 26) {
x = 0;
for (int i = 0; i < 26; i++) cnt[i][0] -= cnt[i][1];
go();
}
}
int main() {
string s, t;
cin >> s >> t;
for (int 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 | #include <bits/stdc++.h>
using namespace std;
mt19937_64 rang(
chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
uniform_int_distribution<int> uid(0, lim - 1);
return uid(rang);
}
long long INF = LLONG_MAX;
const long long M = 1000000007;
long long powm(long long, 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 | #include <bits/stdc++.h>
struct iip : public std::pair<int, int> {
char ch;
};
int n, m, k = 26, cnt = 0;
char s[1100000], t[1100000];
iip a[26];
bool cmp(const iip &a, const iip &b) {
if (a.second == b.second) {
return a.first < b.first;
} else if (a.second == 0)
return true;
else if (b.second == 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 | import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.io.IOException;
import java.io.InputStream;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class Main {
pu... | 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 | from collections import Counter
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write... | 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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class SolutionD {
public static void main(String[] args) throws IOException {
Reader reader = new Reader();
String s = reader.readStringValue();
String t = reader.readStr... | 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];
stack<char> dit;
int main() {
string s1, s2;
cin >> s1 >> s2;
int sum = 0;
for (unsigned int i = 0; i < s1.size(); i++) {
if (s1[i] == '?')
sum++;
else
a[int(s1[i] - 'a')]++;
}
while (sum > 0)
for (unsigned int i = 0; i < s2.si... | 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 double PI = 3.14159265358979;
double eps = 1e-5;
map<char, int> mp;
map<char, int> np;
char cp[1200000];
char s[1200000];
char c[1200000];
int main() {
cin >> s;
int i;
for (i = 0; s[i]; i++) {
mp[s[i]]++;
}
cin >> c;
for (i = 0; c[i]; i++) {
np[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;
long long S[30];
long long T[30];
int main() {
ios_base::sync_with_stdio(0);
vector<long long> V;
string s, t;
long long c = 0;
cin >> s >> t;
for (long long i = 0; i < s.size(); i++) {
if (s[i] == '?')
c++;
else
S[s[i] - 'a']++;
}
for (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 | 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 |
import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline
hist1=[0]*26
hist2=[0]*26
need=[0]*26 # characters needed
remain=0
s=input().strip()
for i in s:
if i=='?': remain+=1
else: hist1[ord(i)-ord('a')]+=1
t=input().strip()
for i in t:
hist2[ord(i)-ord('a')]+=1
while remain:
# find sui... | 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;
using ll = long long;
using vi = vector<long long>;
using vl = vector<long long>;
using pii = pair<long long, long long>;
using pll = pair<long long, long long>;
const long long DX[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0},
DY[9] = {-1, 0, 1, 0, -1, 1, 1, -1, 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;
string s, t, f;
long long int c[27], q, d[27], o[27];
int main() {
cin >> s;
cin >> t;
f = s;
for (int i = 0; i < s.length(); i++)
if (s[i] != '?')
c[s[i] - 'a']++, o[s[i] - 'a']++;
else
q++;
for (int i = 0; i < s.length(); i++) {
if (c[t[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 int limite = 2000000;
char buff[limite];
string leer() {
scanf("%s", buff);
return string(buff);
}
int ns, nt;
string s, t;
int cs[26];
int ms[26];
int ct[26];
int vacios = 0;
int computa(int i) {
if (ct[i] == 0) return limite;
return (cs[i] + ms[i]) / ct[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.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import javax.swing.plaf.synth.SynthSpinnerUI;
import javax.swing.text.AbstractDocument.LeafElement;
public class Main2 {
public static void... | 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.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;
public class Main {
InputStream is;
PrintWriter out;
String INPUT = "";
private static final long M = 1... | 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 os
import sys
from io import BytesIO, IOBase
import math
from queue import Queue
import collections
import itertools
import bisect
import heapq
# sys.setrecursionlimit(100000)
# ^^^TAKE CARE FOR MEMORY LIMIT^^^
import random
def main():
pass
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
de... | 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.*;
import java.util.LinkedList;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
char[] s = sc.next().toCharArray(), t = sc.... | 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.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;
public class SuitableReplacementE25D {
public static void main(String[] args) throws IOException {
FastScanner in = new FastScanner();
String s = in.nextLine();
String pattern = in.next... | 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 | //package CF;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class A {
public static void main(String[] args) throws Exception {
Scanner sc = ne... | 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 ara[30], f_s[200], f_t[200];
int vis[30];
queue<int> q;
int main() {
std::ios_base::sync_with_stdio(false);
cin.tie(0);
string s, t;
cin >> s >> t;
int len = s.size();
for (int i = 0; i < len; i++) {
if (s[i] >= 'a' && s[i] <= 'z') {
f_s[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 | #include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 10;
const long long maxchar = 300;
string s, t;
int cnts[maxchar], cntt[maxchar];
int alc[maxchar];
int ans;
void solve() {
int tempcnt = 10000000;
for (long long(i) = (long long)('a'); (i) <= (long long)('z'); ++(i)) {
if (cntt[i] != 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 |
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int[] int1 = new int[256];
int[] int2 = new int[265];
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 | 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;
long long s[500];
long long t[500];
long long needs[500];
int have = 0;
string sss, ttt;
bool valid(long long x) {
long long test = 0;
for (int i = 'a'; i <= 'z'; i++) {
if (t[i] * x > s[i]) {
test += t[i] * x - s[i];
}
}
return (test <= have);
}
int m... | 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=list(input()),list(input())
os=[0 for i in range(26)]
for i in s:
if i!='?':
os[ord(i)-ord('a')]+=1
i=j=0
while i<len(s):
if s[i]=='?':
j=(j+1)%len(t)
if os[ord(t[j])-ord('a')]>0:
os[ord(t[j])-ord('a')]-=1
i-=1
else:
s[i]=t[j]
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 | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
/**
* Created by aps36017 on 14/7/17.
*/
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = br.read... | 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 ms[26];
int mt[26];
int mp[26];
string s, t;
int main() {
cin >> s >> t;
int q = 0;
for (int i = 0; i < s.size(); i++) {
if (s[i] == '?')
q++;
else
ms[s[i] - 'a']++;
}
for (int i = 0; i < t.size(); i++) {
mt[t[i] - 'a']++;
}
vector<... | 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.*;
/**
* todo unsolved
*/
public class Problem825D {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s = in.next();
String t = in.next();
String x = solve(s, t);
System.out.println(x);
}
private static String solve(String s, String t) ... | 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.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;
public class Main implements Runnable
{
static class InputReader
{
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private SpaceCharFi... | 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, f;
cin >> s;
cin >> f;
int a[27] = {0};
int k = 0;
int n = s.length();
;
for (int i = 0; i < n; i++) {
if (s[i] == '?') {
k++;
} else {
int x = s[i] - 'a';
a[x]++;
}
}
int m = f.length();
vector<char... | 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 | /**
* @author Finn Lidbetter
*/
import java.util.*;
import java.io.*;
import java.awt.geom.*;
public class TaskD {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
String s1 = br... | 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;
int a[200], z;
int main() {
cin >> s >> t;
for (int i = 0; i < s.size(); i++) {
a[s[i]]++;
}
for (int i = 0; i < s.size(); i++) {
if (s[i] == '?') {
z++;
z %= t.size();
if (a[t[z]] > 0) {
a[t[z]]--;
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;
if (s.size() >= t.size()) {
map<char, long long> ms;
map<char, long long> mt;
for (long long i = 0; i < s.size(); i++) ms[s[i]]++;
for (long long i = 0; i < t.size(); i++) mt[t[i]]++;
string x;
while (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 | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
OutputWriter out = new OutputWriter(outputStream);
... | 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 | from collections import Counter
A = input()
AC = Counter(A)
B = input()
BC = Counter(B)
letters = [chr(ord('a') + i) for i in range(ord('z') - ord('a') + 1)]
result = 0
a, b, c = 0, len(A) + 1, 0
#for k in range(len(A) - len(B) + 1):
# needed = 0
# for x in letters:
# needed += max([0, k * BC[x] - AC... | 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;
const int N = 1000001;
int n1, n2, f1[26], f2[26], q;
char s[N], t[N];
vector<int> v;
int main() {
scanf("%s%s", s, t);
n1 = strlen(s);
n2 = strlen(t);
for (int i = 0; i < n1; i++) {
if (s[i] == '?') {
q++;
v.push_back(i);
} else
f1[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;
map<char, int> freq;
string a, b;
vector<int> v;
int main() {
cin >> a >> b;
for (int i = 0; a[i]; ++i) {
if (a[i] == '?')
v.push_back(i);
else
freq[a[i]]++;
}
int i = 0;
while (i < v.size()) {
for (auto j : b) {
if (freq[j] > 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;
template <typename T>
ostream &operator<<(ostream &cout, vector<T> &a) {
for (size_t i = 0; i < a.size(); ++i) cout << a[i] << " ";
return cout;
}
template <typename T>
ostream &operator<<(ostream &cout, vector<vector<T> > &a) {
for (size_t i = 0; i < a.size(); ++i) 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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class D {
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
String ss = br.readLine();
... | 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 sys
input = sys.stdin.readline
def solve():
s = input().strip()
t = input().strip()
t_dict = {}
s_dict = {}
for c in t:
if c in t_dict:
t_dict[c] += 1
else:
t_dict[c] = 1
s_dict[c] = 0
for c in s:
if c in s_dict:
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 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
... | 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() {
ios::sync_with_stdio(0);
cin.tie(NULL);
string s, t;
cin >> s >> t;
long n = s.size(), m = t.size();
unordered_map<char, stack<long> > storage;
for (long i = 0; i < n; ++i) storage[s[i]].push(i);
for (long i = 0; i < n; ++i) {
char goal = t[... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.