output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include <bits/stdc++.h> using namespace std; int main() { int n, usedleft[30], usedright[30], angka, a, b; char left[150010], right[150010]; vector<int> posisileft[30], posisiright[30]; vector<pair<int, int> > daftar; scanf("%d\n%s\n%s", &n, left, right); memset(usedleft, 0, sizeof usedleft); memset(used...
### Prompt In Cpp, your task is to solve the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot...
#include <bits/stdc++.h> using namespace std; struct node { int cnt; vector<int> v; } u[27], v[27]; set<pair<int, int>> s; int main() { int n; string a, b; cin >> n >> a >> b; for (int i = 0; i < n; i++) { if (a[i] == '?') { u[26].cnt++; u[26].v.push_back(i + 1); } else { u[a[i] - ...
### Prompt Create a solution in cpp for the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot ...
#include <bits/stdc++.h> using namespace std; signed main() { int n; cin >> n; string left, right; unordered_map<char, vector<int>> kol_left, kol_right; cin >> left >> right; for (int i = 0; i < n; i++) { char c = left[i]; kol_left[c].push_back(i); } for (int i = 0; i < n; i++) { char c = ri...
### Prompt Please provide a CPP coded solution to the problem described below: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the...
#include <bits/stdc++.h> using namespace std; using lld = long long; using vi = vector<lld>; using vvi = vector<vi>; using pii = pair<lld, lld>; using vpii = vector<pii>; int main() { int n; scanf("%d", &(n)); vpii result; vvi r(27), l(27); for (int i = 1; i <= n; i++) { char c; scanf(" %c", &(c)); ...
### Prompt Your challenge is to write a Cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the...
#include <bits/stdc++.h> using namespace std; long long n, i, x; vector<long long> A[110], B[110]; vector<pair<long long, long long> > Z; char ct; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; for (i = 1; i <= n; i++) { cin >> ct; x = ct - 'a'; if (ct == '...
### Prompt Your task is to create a CPP solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-t...
#include <bits/stdc++.h> using namespace std; vector<int> all[2], s[2][26]; vector<pair<int, int> > ans; string l, r; int n; int main() { cin >> n >> l >> r; for (int i = 0; i < n; i++) { if (l[i] == '?') all[0].push_back(i + 1); else s[0][l[i] - 'a'].push_back(i + 1); } for (int i = 0; i < ...
### Prompt Your task is to create a Cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-t...
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-18; const long double PI = 3.141592653589793238; const long long MOD = 1e9 + 7; const int N = int(5e5) + 10; vector<pair<int, int> > ans; vector<int> aa[26], bb[26], qa, qb; int n; string a, b; bool v[N], vi[N]; int main() { cin >> n >> a >> b; ...
### Prompt Please create a solution in Cpp to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n; cin >> n; string s1, s2; cin >> s1 >> s2; vector<long long> l[26], r[26]; vector<long long> k1, k2; for (long long i = 0; i < n; i++) { ...
### Prompt Develop a solution in CPP to the problem described below: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left...
#include <bits/stdc++.h> using namespace std; int n; queue<pair<int, int> > q_ed; queue<int> q1[27]; queue<int> q2; string s1, s2; int main() { cin >> n >> s1 >> s2; pair<int, int> p; for (int i = 0; i < n; i++) { if (s1[i] == '?') q1[26].push(i); else { int k = s1[i] - 'a'; q1[k].push(i...
### Prompt Your task is to create a Cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-t...
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2; int nn; cin >> nn; cin >> s1 >> s2; list<int> f1[27], f2[27]; map<int, int> s; map<int, int>::iterator is; int c = 0; for (int i = 0; s1[i]; i++) { if (s1[i] == '?') { f1[26].push_back(i); } else f1[s1[i] - '...
### Prompt Please provide a Cpp coded solution to the problem described below: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const int inf = int(2e9); const int _inf = -inf; const int mod = inf + 7; vector<int> gr1[26]; vector<int> gr2[26]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; string s1, s2; cin >> n >> s1 >> s2; ...
### Prompt Please formulate a CPP solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left...
#include <bits/stdc++.h> using namespace std; long long n; long long m; struct node { queue<int> p; int cnt; } l[200005], r[200005]; struct aaa { int x; int y; aaa(){}; aaa(int X, int Y) { x = X; y = Y; } }; queue<aaa> q; int nn = 0; int main() { std::cin >> n; char ch; for (int i = 1; i <= ...
### Prompt Your challenge is to write a cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the...
#include <bits/stdc++.h> using namespace std; int n; bool inv = false; string s1, s2; set<pair<int, int> > set1, set2; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; cin >> s1; cin >> s2; int c1 = 0, c2 = 0; for (char c : s1) c1 += (c == '?') ? 1 : 0; for (char c : s2) c2 += (c == '?')...
### Prompt Develop a solution in cpp to the problem described below: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left...
#include <bits/stdc++.h> using namespace std; int main() { vector<pair<int, int> > sol; vector<int> v1[30], v2[30]; int n; string s1, s2; cin >> n >> s1 >> s2; for (int i = 0; i < s1.size(); i++) if (s1[i] >= 'a' && s1[i] <= 'z') v1[s1[i] - 'a'].push_back(i); else v1[26].push_back(i); ...
### Prompt Generate a cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot an...
#include <bits/stdc++.h> using namespace std; vector<int> b1[30], b2[30], w1, w2; int n; char s1[200005]; char s2[200005]; vector<pair<int, int> > ans; int main() { scanf("%d", &n); scanf("%s %s", s1 + 1, s2 + 1); for (int i = 1; i <= n; ++i) { if (s1[i] == '?') w1.push_back(i); else b1[s1[i] ...
### Prompt Please formulate a CPP solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left...
#include <bits/stdc++.h> using namespace std; long long const max1 = 3e5 + 5; long long const mod = 998244353; long long inf = 1e18; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); long long tc = 1; while (tc--) { long long n; cin >> n; map<char, stack<long long>> left, right; string l, r;...
### Prompt In CPP, your task is to solve the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot...
#include <bits/stdc++.h> using namespace std; int c[150000 + 2], d[150000 + 2]; int main() { vector<int> a[27], b[27]; int n = (cin >> n, n); string s, z; cin >> s >> z; vector<pair<int, int> > f; for (long long i = 0; i < n; i++) { if (s[i] != '?') a[s[i] - 'a'].push_back(i); else a[26]...
### Prompt Construct a CPP code solution to the problem outlined: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left bo...
#include <bits/stdc++.h> using namespace std; int main() { int n, j = 0, p, d, e, g, v, sum = 0, q = 0, u = 0, t, i, a, b, f, h, k, x = -1, y = 0, z = 0; cin >> n; char l[n + 1], r[n + 1]; cin >> l >> r; map<int, int> mp, mp1; set<int> st[27], st1[27], st2, st3; set<int>::iterator it, it1; vect...
### Prompt Generate a CPP solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot an...
#include <bits/stdc++.h> using namespace std; queue<long long> g[256]; int main() { long long n; vector<pair<long long, long long> > an; string s, ss; cin >> n >> s >> ss; for (long long i = 0; i < ss.size(); i++) g[ss[i]].push(i); for (long long i = 0; i < s.size(); i++) if (s[i] != '?') { if (g[...
### Prompt In CPP, your task is to solve the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot...
#include <bits/stdc++.h> using namespace std; list<int> anum[30]; list<int> bnum[30]; list<int> outa, outb; string a, b; int sum = 0; int main() { int n; cin >> n; cin >> a >> b; for (int i = 1; i <= n; i++) if (a[i - 1] != '?') anum[a[i - 1] - 'a' + 1].push_back(i); else anum[0].push_back(i...
### Prompt In cpp, your task is to solve the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot...
#include <bits/stdc++.h> using namespace std; int a[27][150000] = {0}; int b[27] = {0}; int ll[150000] = {0}, rr[150000] = {0}; int o = 0; int mmp[150000] = {0}; int p = 0; int main() { std::ios::sync_with_stdio(0); string l, r; int n, cnt = 0; cin >> n >> l >> r; for (int i = 0; i < l.length(); i++) { if...
### Prompt Please provide a CPP coded solution to the problem described below: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const long long High = 1e16; void ControlIO(); void TimerStart(); void TimerStop(); template <typename Arg1> void ZZ(const char *name, Arg1 &&arg1) { std::cerr << name << " = " << arg1 << endl; } template <typename Arg1, typename... Args>...
### Prompt Please provide a Cpp coded solution to the problem described below: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string l, r; cin >> l >> r; vector<stack<int>> l_array; vector<stack<int>> r_array; for (int i = 0; i < 27; i++) { stack<int> buf; l_array.push_back(buf); r_array.push_back(buf); } for (int i = 0; i < n; i++) { ...
### Prompt Create a solution in Cpp for the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot ...
#include <bits/stdc++.h> using namespace std; signed main() { long long n; cin >> n; string str1, str2; cin >> str1; cin >> str2; vector<long long> adj[27]; vector<long long> adj2[27]; for (long long i = 0; i < n; i++) { if (str1[i] == '?') adj[26].push_back(i + 1); else adj[str1[i] ...
### Prompt Construct a cpp code solution to the problem outlined: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left bo...
#include <bits/stdc++.h> using namespace std; bool b[200020]; int main() { int n; vector<pair<int, int>> ans; string l, r; cin >> n >> l >> r; map<char, vector<int>> mp; for (int i = 0; i < n; i++) { mp[r[i]].push_back(i + 1); } for (int i = 0; i < n; i++) { if (mp[l[i]].size() > 0 && l[i] != '?...
### Prompt Your challenge is to write a CPP solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the...
#include <bits/stdc++.h> using namespace std; int main() { long long i, j, k, sum, q, x, z, p, y, e, n, m, kmax, maxi, t, mini, v, x1, x2, y1, y2, g, kol, w; cin >> n; string l, r; cin >> l; cin >> r; vector<long long> b[27], a[27]; for (i = 0; i < n; i++) { if (l[i] == '?') { a[26].push_b...
### Prompt In CPP, your task is to solve the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot...
#include <bits/stdc++.h> using namespace std; mt19937 rnd(77); int main() { cin.tie(0); cout.tie(0); cin.sync_with_stdio(0); cout.sync_with_stdio(0); ; long long a; cin >> a; string t1, t2; cin >> t1 >> t2; vector<pair<long long, long long>> o; map<char, int> m1, m2; long long vop1 = 0, vop2 = 0...
### Prompt Create a solution in cpp for the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot ...
#include <bits/stdc++.h> using namespace std; template <typename dataType> dataType nthGrayCode(dataType n) { return (n ^ (n >> 1)); } template <typename dataType> void generateAllSubset(vector<dataType> &data) { int i, j, n; n = data.size(); for (i = 0; i < (1 << n); i++) { for (j = 0; j < n; j++) { ...
### Prompt Generate a Cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot an...
#include <bits/stdc++.h> using namespace std; vector<int> one[26], two[26]; vector<int> uone, utwo; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; string left, right; cin >> left >> right; vector<int> q1, q2; for (int i = 0; i < left.size(); ++i) { i...
### Prompt In cpp, your task is to solve the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; const long long inf = 100000000000011; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; string a, b; cin >> a >> b; set<pair<char, int>> x, y, l, r; int cnt1 = 0; int cnt2 = ...
### Prompt Please formulate a cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left...
#include <bits/stdc++.h> using namespace std; stack<int> a[27]; stack<int> b[27]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int n; cin >> n; string f, s; cin >> f >> s; for (int i = 0; i < f.size(); ++i) { if (f[i] == '?') { a[26].push(i + 1); } else { a...
### Prompt Your task is to create a CPP solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-t...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; void solve() { ios_base ::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n; cin >> n; string l, r; cin >> l >> r; vector<vector<long long>> left(26); vector<vector<long long>> right(26); vector<long long> ul; vect...
### Prompt Please provide a CPP coded solution to the problem described below: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the...
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-8; const double pi = acos(-1); long long dcmp(double a, double b) { return fabs(a - b) <= EPS ? 0 : a < b ? -1 : 1; } void debug() {} int const N = 200000 + 9, M = 100 + 9, OO = 1e9; vector<vector<int>> vec1(130); vector<vector<int>> vec2(130); vecto...
### Prompt Generate a cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot an...
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j; cin >> n; string s1, s2; cin >> s1; cin.ignore(); cin >> s2; vector<vector<int> > l(26); vector<int> q; for (i = 0; i < s1.length(); i++) { if (s1[i] != '?') l[s1[i] - 'a'].push_back(i); else q.push_back(i); ...
### Prompt Construct a Cpp code solution to the problem outlined: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left bo...
#include <bits/stdc++.h> using namespace std; bool isPrime(long long int n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (long long int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; } int main() { ios:...
### Prompt Construct a cpp code solution to the problem outlined: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left bo...
#include <bits/stdc++.h> using namespace std; int main() { vector<int> k; vector<int> h; vector<pair<int, int> > ans; vector<int> vl[27]; vector<int> vr[27]; int n; cin >> n; string l, r; cin >> l; cin >> r; for (int i = 0; i < n; i++) { if (l[i] != '?') { vl[l[i] - 'a'].push_back(i); ...
### Prompt Create a solution in CPP for the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 150000 + 5; int n; string a, b; vector<int> A[30], B[30]; int cntA[30], cntB[30], take[30]; vector<pair<int, int> > res; int idx(char k) { if (k == '?') return 26; return (int)(k - 'a'); } int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);...
### Prompt Your task is to create a Cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-t...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const int INF = 1e9; const long long IINF = 1e18; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; const char dir[4] = {'D', 'R', 'U', 'L'}; template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : ...
### Prompt Construct a cpp code solution to the problem outlined: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left bo...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int inf = 0x3f3f3f3f; const int maxn = 2e5 + 5; char a[maxn], b[maxn]; int n; using pii = pair<int, int>; vector<pii> ans; vector<int> f[26], g[26]; set<int> s1, s2; int main() { ios::sync_with_stdio(false); cin >> n; cin >> (a + 1) >> (b +...
### Prompt Construct a CPP code solution to the problem outlined: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left bo...
#include <bits/stdc++.h> using namespace std; int n, m, k; bitset<31> vis; int dx[6] = {-1, 1, 0, 0, 0, 0}; int dy[6] = {0, 0, -1, 1, 0, 0}; int dz[6] = {0, 0, 0, 0, -1, 1}; int valid(int z, int x, int y) { if (z < 0 || z >= k || x < 0 || x >= n || y < 0 || y >= m) return 0; return 1; } int main() { ios_base::syn...
### Prompt Your task is to create a Cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-t...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; const int inf = 0x3f3f3f3f; const long long INF = (long long)1e18 + 6; queue<int> q1[30], q2[30]; vector<pair<int, int>> ans; int main() { int n; cin >> n; string s, t; cin >> s >> t; for (int i = 0; i < n; i++) { if (s[i] == '?') ...
### Prompt Please provide a CPP coded solution to the problem described below: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long N, PL, PR; string L, R; vector<vector<long>> CL, CR; vector<pair<long, long>> Answer; cin >> N; cin.clear(); cin.ignore(32767, '\n'); getline(cin, L); getline(cin, R); L =...
### Prompt Your task is to create a Cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-t...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string a, b; cin >> a >> b; map<char, vector<int>> ma, mb; for (int i = 0; i < n; i++) { ma[a[i]].push_back(i + 1); mb[b[i]].push_back(i + 1); } vector<pair<int, int>> ans; int l1 = 0, l2 = 0; for (int i = 'a'; i <= ...
### Prompt Your task is to create a cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-t...
#include <bits/stdc++.h> using namespace std; long long n, m, k; char s[200005]; vector<long long> cnt[3][202]; vector<pair<long long, long long> > res; int main() { long long i, j; scanf("%lld", &n); scanf("%s", &s); for (i = 0; i <= n - 1; i++) { cnt[1][s[i]].push_back(i + 1); } scanf("%s", &s); for...
### Prompt Please formulate a Cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left...
#include <bits/stdc++.h> using namespace std; const int maxn = 150000 + 10; string l, r; vector<int> vl[30], vr[30]; stack<int> cl, cr; vector<pair<int, int> > ans; int n, vis_l[maxn], vis_r[maxn]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> l >> r; for (int i = 0; i < n; i+...
### Prompt Please formulate a CPP solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left...
#include <bits/stdc++.h> using namespace std; long long int binpow(long long int a, long long int b) { long long int res = 1; while (b > 0) { if (b & 1) res = res * a; a = a * a; b >>= 1; } return res; } void solve() { long long int n; cin >> n; string s; cin >> s; string sec; cin >> sec...
### Prompt Your challenge is to write a Cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the...
#include <bits/stdc++.h> using namespace std; queue<int> lm[30]; queue<int> rm[30]; int main() { int n, idx; cin >> n; string l, r; cin >> l >> r; for (int i = 0; i < n; i++) { if (l[i] >= 'a' && l[i] <= 'z') { lm[l[i] - 'a'].push(i + 1); } else lm[26].push(i + 1); } for (int i = 0; i ...
### Prompt Your task is to create a Cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-t...
#include <bits/stdc++.h> using namespace std; void test() { long long n; cin >> n; string a, b; cin >> a >> b; map<char, vector<long long>> mp; for (long long i = 0; i < n; i++) mp[b[i]].push_back(i); vector<pair<long long, long long>> ans; vector<bool> vis1(n, 0), vis2(n, 0); for (long long i = 0; i ...
### Prompt Your task is to create a cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-t...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string left; multimap<char, int> m; multimap<char, int>::iterator itr; cin >> left; string right; cin >> right; for (int i = 0; i < n; i++) { m.insert({right[i], i}); } vector<vector<int> > v; vector<int> qm[1]; fo...
### Prompt Construct a Cpp code solution to the problem outlined: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left bo...
#include <bits/stdc++.h> using namespace std; int x[200005], f[200005], ans[200005]; multimap<char, int> s; vector<pair<int, int>> v; int main() { int n; string a, b; cin >> n >> a >> b; for (int i = 0; i < n; i++) { s.insert(pair<char, int>(b[i], i + 1)); } for (int i = 0; i < n; i++) { if (s.find(...
### Prompt Develop a solution in cpp to the problem described below: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left...
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; string str1, str2; cin >> str1 >> str2; unordered_map<char, vector<int> > mp; for (int i = 0; i < n; i++) { mp[str2[i]].push_back(i); } vector<pair<int, int> > ans; set<int> s2; set<int> s1; for (int i = 0; i...
### Prompt Your task is to create a cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-t...
#include <bits/stdc++.h> using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __print(float x) { cer...
### Prompt Create a solution in CPP for the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string a, b; cin >> a >> b; map<char, vector<int> > m; for (int i = 0; i < n; i++) { m[a[i]].push_back(i); } vector<pair<int, int> > v; vector<int> left; bool visited[n]; for (int i = 0; i < n; i++) visited[i] = false;...
### Prompt Generate a Cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot an...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; string l, r; cin >> n >> l >> r; vector<pair<int, int>> ans; vector<vector<int>> lc(256), rc(256); for (int i = 0; i < n; i++) { lc[l[i]].push_back(i); rc[r[i]]....
### Prompt In cpp, your task is to solve the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int N; cin >> N; set<int> A[28]; set<int> B[28]; for (int i = 0; i < N; i++) { char c; cin >> c; int id = (c == '?') ? 26 : c - 'a'; A[id].insert(i); } for (int i = 0; i < N; i++) { ...
### Prompt Please create a solution in CPP to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left...
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } inline int readInt() { int x; scanf("%d", &x); return x; } const double E...
### Prompt Please formulate a CPP solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 15; const int INF = 0x3f3f3f3f; const int mod = 1e9 + 7; const int maxnode = 1e6 + 5; char lt[maxn], rt[maxn]; vector<pair<int, int> > ans; vector<int> lcnt[30], rcnt[30]; int psl[30], psr[30]; int main() { ios::sync_with_stdio(0); cin.tie(0), cou...
### Prompt Generate a CPP solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot an...
#include <bits/stdc++.h> using namespace std; const int N = 5000; const int H = 1e9; const int sx[4] = {1, -1, 0, 0}; const int sy[4] = {0, 0, 1, -1}; mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count()); bool use[150000]; bool uss[150000]; int main() { srand(time(0)); ios_base::sync_with_st...
### Prompt Construct a CPP code solution to the problem outlined: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left bo...
#include <bits/stdc++.h> using namespace std; long long int c[1010][1010]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; string s1, s2; cin >> s1 >> s2; map<char, set<int> > mp; for (int i = 0; i < n; i++) { mp[s1[i]].insert(i + 1); } int k = 0; vec...
### Prompt Please provide a Cpp coded solution to the problem described below: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the...
#include <bits/stdc++.h> using namespace std; int n; int lcnt[27], rcnt[27]; vector<int> idxl[27], idxr[27]; int sofar[26], sofar_ql, sofar_qr; int ans; void count(char *s, int *arr, vector<int> *idx) { int j = 1; while (*s) { int i; if (*s == '?') i = 26; else i = *s - 'a'; idx[i].push_...
### Prompt Create a solution in cpp for the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot ...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; int taken[200]; int done[200]; int main() { int n; string a, b; cin >> n >> a >> b; deque<int> v1[200]; deque<int> v2[200]; for (int i = 0; i < n; i++) v1[a[i]].push_back(i + 1); for (int i = 0; i < n; i++) v2[b[i]].push_back(i + 1)...
### Prompt In Cpp, your task is to solve the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot...
#include <bits/stdc++.h> using namespace std; const int N = 200005; int n; string a, b; vector<int> g1[26], g2[26]; vector<int> a1, a2; vector<pair<int, int>> ans; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; cin >> a; cin >> b; for (int i = 0; i < n; i++) { if (a[i] == '?') { a1.pu...
### Prompt Create a solution in cpp for the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot ...
#include <bits/stdc++.h> const int N = 2e5 + 5; const int MOD = 1e9 + 7; using namespace std; int n; char str1[N], str2[N]; vector<int> lt[30], rt[30]; vector<pair<int, int> > ans; int main() { scanf("%d", &n); scanf(" %s", str1); scanf(" %s", str2); for (int a = 0; a < n; a++) { if (str1[a] == '?') l...
### Prompt Your task is to create a cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-t...
#include <bits/stdc++.h> using namespace std; vector<int> A[27], B[27]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; string a, b; cin >> n >> a >> b; for (int i = 0; i < n; i++) { if (a[i] == '?') A[26].push_back(i + 1); else { A[a[i] - 'a'].push...
### Prompt Develop a solution in Cpp to the problem described below: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left...
#include <bits/stdc++.h> using namespace std; void solve() { long long n; cin >> n; string l, r; cin >> l >> r; vector<vector<int>> mp1(27); vector<vector<int>> mp2(27); vector<long long> qs; vector<long long> qs2; for (long long i = 0; i < n; i++) { if (l[i] == '?') { qs.push_back(i); }...
### Prompt Please create a solution in CPP to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; long long int n; cin >> n; string s1, s2; cin >> s1 >> s2; vector<long long int> v1[1000], v2[1000]; for (long long int i = 0; i < s1.length(); i++) { v1[s1[i]].push_back(i + 1...
### Prompt In CPP, your task is to solve the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot...
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 5; char l[MAXN]; char r[MAXN]; vector<int> lch2inds[200]; vector<int> rch2inds[200]; vector<pair<int, int> > ansP; int main() { int n; scanf("%d", &n); scanf(" %s", l + 1); scanf(" %s", r + 1); for (int i = 1; i <= n; ++i) { lch2inds[l[i...
### Prompt Please provide a CPP coded solution to the problem described below: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the...
#include <bits/stdc++.h> using namespace std; const int N = 220000; char a[N], b[N]; int cnt[2][N]; int deg[2][N]; vector<int> v1[N], v2[N]; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; cin >> a >> b; for (int i = 0; a[i]; i++) v1[a[i]].push_back(i); for (int i = 0; b[i]; i++) v2[b[i]].push_b...
### Prompt Please create a solution in CPP to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left...
#include <bits/stdc++.h> using namespace std; map<char, vector<int> > A, B; int main(int argc, char** argv) { int N; cin >> N; string a, b; cin >> a >> b; int idx = 1; for (const auto& c : a) { if (!A.count(c)) A[c] = vector<int>(); A[c].push_back(idx); idx++; } idx = 1; for (const auto& c...
### Prompt Construct a CPP code solution to the problem outlined: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left bo...
#include <bits/stdc++.h> using namespace std; const int A = 26; int main() { int n; cin >> n; string l; cin >> l; vector<vector<int>> left(A); vector<int> wl; for (int i = 0; i < int(n); i++) if (l[i] != '?') left[l[i] - 'a'].push_back(i); else wl.push_back(i); string r; cin >> r; ...
### Prompt Create a solution in CPP for the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot ...
#include <bits/stdc++.h> const int inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3fLL; const double dinf = inf; using namespace std; const int N = 150000 + 10; const double eps = 1e-10; const double PI = acos(-1.0); const int dx[4] = {0, 1, 0, -1}; const int dy[4] = {1, 0, -1, 0}; int n; char l[N], r[N]; int ...
### Prompt Construct a Cpp code solution to the problem outlined: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left bo...
#include <bits/stdc++.h> using namespace std; void boost() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } long long power(long long n, long long p) { long long i, ans = 1; for (i = 0; i < p; i++) ans = (ans * n) % 1000000007; return ans; } bool func(const pair<char, long long> &a, cons...
### Prompt Please provide a Cpp coded solution to the problem described below: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the...
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; long long int a, b, c, ans, d, e, f, g, h[100005], h1[200], arr[100005], used[1000005]; string s, s1; vector<long long int> v; pair<char, long long int> sc[1000007], s1c[1000007]; char ch; int main() { cin >> a >> s >> s1; for (long long ...
### Prompt Please create a solution in Cpp to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left...
#include <bits/stdc++.h> using namespace std; const int N = 3e4 + 2, K = 20; const int mod = 1e9 + 7; vector<int> lf[27]; vector<int> rf[27]; int main() { int n; cin >> n; string a, b; cin >> a >> b; for (int i = 0; i < n; i++) { if (a[i] != '?') { lf[a[i] - 'a'].push_back(i + 1); } else { ...
### Prompt Your challenge is to write a Cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 7; int a[N], f[N]; queue<int> idx[27]; vector<pair<int, int> > ans; int main() { ios_base ::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; string l, r; cin >> n >> l >> r; for (int i = 0; i < n; i++) { if (l[i] == '?') idx[26...
### Prompt Create a solution in CPP for the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot ...
#include <bits/stdc++.h> using namespace std; queue<int> q1[30], q2[30]; vector<pair<int, int>> ans; int main() { int n; cin >> n; string s, t; cin >> s >> t; for (int i = 0; i < n; i++) { if (s[i] == '?') q1[26].push(i + 1); else q1[s[i] - 'a'].push(i + 1); if (t[i] == '?') q2[2...
### Prompt In Cpp, your task is to solve the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 1000 * 1000 + 10; int main() { int n; cin >> n; string l, r; cin >> l >> r; map<char, queue<int>> mp; map<char, bool> check; map<int, bool> check1, check2; int cnt = 1; for (auto i : r) { check[i] = true; m...
### Prompt Construct a cpp code solution to the problem outlined: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left bo...
#include <bits/stdc++.h> using namespace std; char ch1[150005], ch2[150005]; int main() { int n, i; int c1[28] = {0}; int c2[28] = {0}; scanf("%d", &n); scanf("%s", ch1 + 1); scanf("%s", ch2 + 1); int sum = 0; vector<int> pos1[28], pos2[28]; for (i = 1; i <= n; i++) { if (ch1[i] >= 'a' && ch1[i] <...
### Prompt Create a solution in CPP for the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot ...
#include <bits/stdc++.h> using namespace std; const long double PI = 3.141592653589793238L; void init() { cin.tie(0); cin.sync_with_stdio(0); } int main() { init(); int n; cin >> n; string l, r; cin >> l >> r; vector<int> left[26]; vector<int> right[26]; vector<int> leftQ; vector<int> rightQ; fo...
### Prompt Your task is to create a cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-t...
#include <bits/stdc++.h> using namespace std; template <typename T> std::ostream &operator<<(std::ostream &out, vector<T> &v) { for (typename vector<T>::size_type i = 0; i < v.size(); ++i) out << v[i] << " "; out << "\n"; return out; } template <typename T, typename N> std::ostream &operator<<(std::ostream &o...
### Prompt Create a solution in Cpp for the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot ...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; const int Mod = 1000000007; const int INF = 0x3f3f3f3f; const long long LL_INF = 0x3f3f3f3f3f3f3f3f; const double e = exp(1); const double PI = acos(-1); const double ERR = 1e-10; char a[maxn], b[maxn]; int cnta[maxn], cntb[maxn]; int quea, queb; v...
### Prompt Your task is to create a CPP solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-t...
#include <bits/stdc++.h> using namespace std; template <typename T> inline void printV(vector<T>& a) { for (int i = 0; i < ((int)((a).size())); i++) { cout << a[i] << " "; } cout << "\n"; } template <typename T> inline void printV(vector<T>& a, int n) { for (int i = 0; i < n; i++) { cout << a[i] << " ";...
### Prompt Please provide a Cpp coded solution to the problem described below: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the...
#include <bits/stdc++.h> using namespace std; int n; char s1[1000010], s2[1000010]; queue<int> p1[200], p2[200]; vector<pair<int, int>> r; int main() { scanf("%d%s%s", &n, s1 + 1, s2 + 1); for (int i = (1); i <= (n); ++i) { p1[s1[i]].push(i); p2[s2[i]].push(i); } for (int i = ('a'); i <= ('z'); ++i) { ...
### Prompt Construct a cpp code solution to the problem outlined: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left bo...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 7; string s, t; int n; vector<pair<int, int> > ans; vector<int> v[2][N]; void add(int a, int b) { while (!v[0][a].empty() && !v[1][b].empty()) ans.push_back({v[0][a].back(), v[1][b].back()}), v[0][a].pop_back(), v[1][b].pop_back(); } int ma...
### Prompt Your challenge is to write a Cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the...
#include <bits/stdc++.h> using namespace std; vector<int> m1[32], m2[32]; signed main() { int n; cin >> n; for (int i = 1; i <= n; i++) { char t; cin >> t; if (t == '?') m1[31].push_back(i); else m1[t - 'a'].push_back(i); } for (int i = 1; i <= n; i++) { char t; cin >> t; ...
### Prompt Develop a solution in Cpp to the problem described below: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left...
#include <bits/stdc++.h> using namespace std; long long GCD(long long a, long long b) { return (b == 0) ? a : GCD(b, a % b); } long long LCM(long long a, long long b) { long long temp = GCD(a, b); return temp ? (a / temp * b) : 0; } int dx[4] = {1, -1, 0, 0}; int dy[4] = {0, 0, 1, -1}; long long oo = 1e18; long lon...
### Prompt Please create a solution in CPP to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left...
#include <bits/stdc++.h> using namespace std; stack<int> S1[31]; stack<int> S2[31]; char st1[150010], st2[150010]; vector<pair<int, int> > res; int main() { int N; scanf("%d", &N); scanf(" %s %s", st1, st2); for (int i = 0; i < N; i++) { S1[st1[i] == '?' ? 30 : st1[i] - 'a'].push(i + 1); S2[st2[i] == '?...
### Prompt Develop a solution in CPP to the problem described below: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string sa, sb; cin >> sa >> sb; map<char, list<int>> a, b; int i = 1; for (auto c : sa) a[c].push_front(i++); i = 1; for (auto c : sb) b[c].push_front(i++); int tot = a['?'].size() + b['?'].size(); for (auto c = 'a'; c <= ...
### Prompt Your task is to create a cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-t...
#include <bits/stdc++.h> using namespace std; const int maxx = 15e4 + 7; const int Inf = 1 << 30; const long long INF = 1ll << 60; int n; char S[maxx], T[maxx]; int s[maxx], t[maxx]; int tot[maxx]; int pos[30][maxx]; bool vis[maxx]; bool visT[maxx]; queue<int> qua; queue<int> que; int ans; struct PP { int ss, tt; } f...
### Prompt Your challenge is to write a cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the...
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int n; cin >> n; string l; l.reserve(n); cin >> l; string r; r.reserve(n); cin >> r; vector<int> lc[26] = {}; vector<int> la; vector<int> rc[26] = {}; vector<int> ra; for (int i =...
### Prompt Construct a CPP code solution to the problem outlined: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left bo...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long int t = 1; while (t--) { long long int n; cin >> n; string l, r; cin >> l >> r; map<char, vector<long long int>> m; map<char, vector<long long int>>...
### Prompt Generate a cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot an...
#include <bits/stdc++.h> using namespace std; ifstream fi("input.txt"); ofstream fo("output.txt"); const int N = 1e5 + 5; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int n, m, k, cnt, rs1; long long maxx = -1e9, minn = 1e9; const int maxn = N; const long long MOD = 1e9 + 7; int rs; vector<int> ...
### Prompt Please create a solution in CPP to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); srand(time(NULL)); ; long long n; cin >> n; string s, second; cin >> s; cin >> second; queue<long long> adj1[27]; queue<long long> adj2[27]; for (long long i = 0; i < n; i++) { ...
### Prompt Your task is to create a Cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-t...
#include <bits/stdc++.h> using namespace std; int main() { int n; string l, r; cin >> n >> l >> r; vector<vector<int>> tmp(27); for (int i = 0; i < n; i++) { if (r[i] == '?') { tmp[26].push_back(i); } else { tmp[r[i] - 'a'].push_back(i); } } vector<pair<int, int>> ans; for (int i...
### Prompt Develop a solution in Cpp to the problem described below: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left...
#include <bits/stdc++.h> using namespace std; int n, i; string s, t; stack<int> l[256], r[256], a, b; void c(stack<int> &x, stack<int> &y) { for (; !x.empty() && !y.empty();) { a.push(x.top()); b.push(y.top()); x.pop(); y.pop(); } } int main() { for (cin >> n >> s >> t; i < n; i++) l[s[i]].push(i)...
### Prompt Please create a solution in CPP to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; string s1, s2; cin >> s1 >> s2; map<char, vector<int>> mp; for (int i = 0; i < n; i++) mp[s2[i]].push_back(i); unordered_set<int> set1, set2, set3, set4; vector<pair<long long...
### Prompt Please provide a Cpp coded solution to the problem described below: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; string s[2]; cin >> n >> s[0] >> s[1]; vector<int> ind[26][2], indq[2]; bool mark[n][2]; memset(mark, 0, sizeof mark); for (int i = 0; i < 2; i++) for (int j = 0; j < n; j++) { cha...
### Prompt Please provide a CPP coded solution to the problem described below: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the...
#include <bits/stdc++.h> using namespace std; char sa[150010]; char sb[150010]; vector<int> a[26]; vector<int> b[26]; vector<int> aq, bq; vector<pair<int, int> > ans; int main() { int n; scanf("%d", &n); scanf("%s %s", sa, sb); for (int i = 0; i < n; i++) { if (sa[i] == '?') aq.push_back(i + 1); e...
### Prompt Construct a cpp code solution to the problem outlined: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left bo...
#include <bits/stdc++.h> using namespace std; const int maxn = 4e5 + 5; using LL = int64_t; vector<int> E[30][3]; vector<pair<int, int>> ans; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; string l, r; cin >> n >> l >> r; for (int i = 0; i < n; i++) { if (l[i] == '?') E[26][0].p...
### Prompt Generate a cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot an...
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; void open() { ((void)0); ((void)0); ((void)0); } const int MAX = 1.5e5; const int MOD = 1e9 + 7; const int INF = 0x3f3f3f3f; const long long LL_INF = 0x3f3f3f3f3f3f3f3fLL; const double PI = acos(-1); const long double ERR = 1e-10; const...
### Prompt Please formulate a Cpp solution to the following problem: There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left...