-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Creating_Words.cpp
More file actions
274 lines (257 loc) · 6.35 KB
/
A_Creating_Words.cpp
File metadata and controls
274 lines (257 loc) · 6.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
// gl hf
// Arkantos_on_vacation
// Created on: 2024-10-15 Tuesday 04:28:33 UTC:+06:00
// CODE ID: 81d45373-6627-4fc5-a538-fb395cbb90af_0d89ed
// Problem Name: A Creating Words
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ull unsigned long long
#define ld long double
#define bl bool
#define vct vector
#define ull unsigned long long
#define vi vector<ll>
#define vl vector<ll>
#define vb vector<bl>
#define pii pair<ll, ll>
#define pll pair<ll, ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define vp vector<pair<ll, ll>>
#define vs vector<string>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define vpvp vector<pair<ll, pair<ll, ll>>>
#define Map map<ll, ll>
#define Set set<ll>
#define PQ priority_queue<ll>
#define MinPQ priority_queue<ll, vector<ll>, greater<ll>>
#define UM unordered_map<ll, ll>
#define US unordered_set<ll>
#define Stk stack<ll>
#define Que queue<ll>
#define Deque deque<ll>
#define OS ordered_set<ll>
#define Rep(i, a, b) for (ll i = (a); i <= (b); ++i)
#define For(i, n) for (ll i = 0; i < (n); ++i)
#define Rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define ForV(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define trav(i, a) for (auto &i : a)
#define sumV(v, i, j) accumulate(v.begin() + i, v.begin() + j + 1)
#define cinAll(v) \
for (auto &x : v) \
cin >> x;
#define coutAll(v) \
for (const auto &x : v) \
cout << x << " ";
#define sumAll(v) accumulate(v.begin(), v.end(), 0LL)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define sortAll(v) sort(v.begin(), v.end())
#define sortMax64(v) sort(v.begin(), v.end(), std::greater<ll>())
#define sortMax32(v) sort(v.begin(), v.end(), std::greater<int>())
#define py cout << "YES" << endl;
#define pn cout << "NO" << endl;
#define ps cout << " " << endl;
#define nocap true
#define cap false
#define print(x) cout << x << endl;
#define ret return;
#define minAll(v) *min_element(v.begin(), v.end())
#define maxAll(v) *max_element(v.begin(), v.end())
#define minV *min_element
#define maxV *max_element
#define minVi *min_element(v.begin(), v.begin() + i)
#define maxVi *max_element(v.begin(), v.begin() + i)
#define firstSet(x) __builtin_ffs(x) - 1
#define countSet(x) __builtin_popcountll(x)
#define leadingZeros(x) __builtin_clz(x)
#define trailingZeros(x) __builtin_ctz(x)
#define parityBit(x) __builtin_parity(x)
#define leadingSignBits(x) __builtin_clrsb(x)
#define byteSwap32(x) __builtin_bswap32(x)
#define byteSwap64(x) __builtin_bswap64(x)
#define addOverflow(a, b, res) __builtin_add_overflow(a, b, res)
#define subOverflow(a, b, res) __builtin_sub_overflow(a, b, res)
#define mulOverflow(a, b, res) __builtin_mul_overflow(a, b, res)
#define inmap(um, x) um.find(x) == um.end()
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = LONG_LONG_MAX;
const ll NEG = -1e9;
const int N = 100000;
long long powers_of_2[N + 1];
long long power_of_2(long long n)
{
long long base = 2;
long long result = 1;
while (n > 0)
{
if (n % 2 == 1)
{
result = (result * base) % MOD;
}
base = (base * base) % MOD;
n /= 2;
}
return result;
}
void precompute_powers_of_2()
{
powers_of_2[0] = 1;
for (int i = 1; i <= N; i++)
{
powers_of_2[i] = (powers_of_2[i - 1] * 2) % MOD;
}
}
long long power_mod(long long n, long long k, long long mod)
{
long long result = 1;
n = n % mod;
while (k > 0)
{
if (k % 2 == 1)
{
result = (result * n) % mod;
}
n = (n * n) % mod;
k /= 2;
}
return result;
}
// Function to check if a number is a power of 2
bool is_power_of_2(long long x)
{
return x > 0 && (x & (x - 1)) == 0;
}
// Function to count the number of set bits (1s) in a number
int count_set_bits(long long x)
{
int count = 0;
while (x > 0)
{
count += x & 1;
x >>= 1;
}
return count;
}
// Function to find the next power of 2 greater than or equal to x
long long next_power_of_2(long long x)
{
if (x <= 0)
return 1;
if (is_power_of_2(x))
return x;
x--;
x |= x >> 1;
x |= x >> 2;
x |= x >> 4;
x |= x >> 8;
x |= x >> 16;
x |= x >> 32;
return x + 1;
}
// Function to compute x^n
long long power(long long x, long long n)
{
long long result = 1;
while (n > 0)
{
if (n % 2 == 1)
{
result *= x;
}
x *= x;
n /= 2;
}
return result;
}
// Function to find the MEX (Minimum Excluded Value) of an array
int find_mex(const vector<int> &arr)
{
unordered_set<int> s(arr.begin(), arr.end());
int mex = 0;
while (s.count(mex))
{
mex++;
}
return mex;
}
// Function to find the MEX of an array with an upper limit
int find_mex_with_limit(const vector<int> &arr, int limit)
{
vector<bool> present(limit + 1, false);
for (int x : arr)
{
if (x <= limit)
present[x] = true;
}
for (int i = 0; i <= limit; i++)
{
if (!present[i])
return i;
}
return limit + 1;
}
// Function to find the MEX in a more memory-efficient way if numbers are small
int find_mex_optimized(const vector<int> &arr, int max_value)
{
vector<int> freq(max_value + 1, 0);
for (int x : arr)
{
if (x <= max_value)
freq[x]++;
}
for (int i = 0; i <= max_value; i++)
{
if (freq[i] == 0)
return i;
}
return max_value + 1;
}
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
os << "{ ";
for (const T &x : v)
os << x << " ";
os << "}";
return os;
}
void solve()
{
string s, t;
cin >> s >> t;
swap(s[0], t[0]);
cout << s << " " << t << endl;
}
// gg wp
int main()
{
const static auto fast = []()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
return 0;
}();
ll t;
if (t != 1)
cin >> t;
while (t--)
{
solve();
}
return 0;
}