Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
B'You are given two strings a and b of length n . Then, you are (forced against your will) to answer q queries. For each query, you are given a range bounded by l and r . In one operation, you can choose an integer i ( l <= q i <= q r ) and set a_i = x where x is any character you desire. Output the minimum number of operations you must perform such that texttt{sorted(a[l..r])} = texttt{sorted(b[l..r])} . The operations you perform on one query does not affect other queries. For an arbitrary string c , texttt{sorted(c[l..r])} denotes the substring consisting of characters c_l, c_{l+1}, ... , c_r sorted in lexicographical order. The first line contains t ( 1 <= q t <= q 1000 ) xe2 x80 x93 the number of test cases. The first line of each test case contains two integers n and q ( 1 <= q n, q <= q 2 cdot 10^5 ) xe2 x80 x93 the length of both strings and the number of queries. The following line contains a of length n . It is guaranteed a only contains lowercase latin letters. The following line contains b of length n . It is guaranteed b only contains lowercase latin letters. The following q lines contain two integers l and r ( 1 <= q l <= q r <= q n ) xe2 x80 x93 the range of the query. It is guaranteed the sum of n and q over all test cases does not exceed 2 cdot 10^5 . For each query, output an integer, the minimum number of operations you need to perform in a new line. For the first query, texttt{sorted(a[1..5])} = abcde and texttt{sorted(b[1..5])} = abcde, so no operations are necessary. For the second query, you need to set a_1 = e. Then, texttt{sorted(a[1..4])} = texttt{sorted(b[1..4])} = bcde. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
272895990 |
Dream_startooo |
C |
July 27, 2024, 3:17 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
10 |
156 |
17612800 |
|
|
272854965 |
XueHua0.1 |
C |
July 26, 2024, 5:39 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
10 |
202 |
41676800 |
|
|
272896053 |
Njasoo |
C |
July 27, 2024, 3:18 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
10 |
202 |
42086400 |
|
|
272892804 |
AAAAAZBX |
C |
July 27, 2024, 2:43 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
10 |
202 |
42086400 |
|
|
272886915 |
soul_kayu |
C |
July 27, 2024, 1:26 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
10 |
202 |
42086400 |
|
|
272884838 |
Phrvth |
C |
July 27, 2024, 12:40 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
10 |
202 |
48128000 |
|
|
272891410 |
smilingandweeping |
C |
July 27, 2024, 2:26 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
10 |
202 |
106188800 |
|
|
272849243 |
liangcheng |
C |
July 26, 2024, 5:03 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
10 |
217 |
38400000 |
|
|
272889400 |
ac2023 |
C |
July 27, 2024, 2:01 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
10 |
217 |
48128000 |
|
|
272865614 |
Saifullah1 |
C |
July 26, 2024, 7:06 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
10 |
218 |
22732800 |
|
|
272873331 |
Mohab_Mohammed7 |
C |
July 26, 2024, 8:41 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
10 |
171 |
17612800 |
|
|
272912416 |
P_t_d |
C |
July 27, 2024, 6 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
10 |
171 |
17612800 |
|
|
272910771 |
ClinZ |
C |
July 27, 2024, 5:47 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
10 |
171 |
17612800 |
|
|
272906161 |
Tyyy |
C |
July 27, 2024, 5:07 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
10 |
171 |
17612800 |
|
|
272905591 |
abhi0 |
C |
July 27, 2024, 5:02 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
10 |
171 |
17612800 |
|
|
272903144 |
xsh367 |
C |
July 27, 2024, 4:37 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
10 |
171 |
17612800 |
|
|
272895342 |
Uniq0rn |
C |
July 27, 2024, 3:10 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
10 |
171 |
17612800 |
|
|
272892953 |
Curry999 |
C |
July 27, 2024, 2:45 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
10 |
171 |
17612800 |
|
|
272852348 |
king_2929 |
C |
July 26, 2024, 5:28 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
10 |
171 |
17612800 |
|
|
272894300 |
D1stance |
C |
July 27, 2024, 2:59 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
10 |
171 |
17817600 |
|
|
272852338 |
huxintt |
C |
July 26, 2024, 5:28 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
10 |
93 |
19968000 |
|
|
272856766 |
_UPG_ |
C |
July 26, 2024, 5:52 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
10 |
124 |
18124800 |
|
|
272857933 |
neal |
C |
July 26, 2024, 6 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
10 |
124 |
18227200 |
|
|
272890454 |
HIHA |
C |
July 27, 2024, 2:14 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
10 |
124 |
39014400 |
|
|
272886899 |
xx_mmc |
C |
July 27, 2024, 1:25 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
10 |
125 |
20889600 |
|
|
272903937 |
knight247 |
C |
July 27, 2024, 4:45 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
10 |
139 |
18124800 |
|
|
272877012 |
gabriel.borges |
C |
July 26, 2024, 9:41 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
10 |
139 |
18124800 |
|
|
272891018 |
xuQingsupup |
C |
July 27, 2024, 2:21 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
10 |
140 |
17715200 |
|
|
272900433 |
uy__uy |
C |
July 27, 2024, 4:06 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
10 |
140 |
18124800 |
|
|
272894561 |
chengjy |
C |
July 27, 2024, 3:02 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
10 |
140 |
18124800 |
|
|
272883710 |
bluemegane |
C |
July 27, 2024, 12:14 a.m. |
OK |
C# 8 |
TESTS |
10 |
843 |
46080000 |
|
|
272862438 |
SanjivDinakar |
C |
July 26, 2024, 6:34 p.m. |
OK |
GNU C11 |
TESTS |
10 |
1171 |
83865600 |
|
|
272854910 |
harshita_77 |
C |
July 26, 2024, 5:39 p.m. |
OK |
GNU C11 |
TESTS |
10 |
4452 |
21299200 |
|
|
272863299 |
Shaurya_Tomer |
C |
July 26, 2024, 6:43 p.m. |
OK |
Java 21 |
TESTS |
10 |
593 |
41779200 |
|
|
272860871 |
ankush9140 |
C |
July 26, 2024, 6:21 p.m. |
OK |
Java 21 |
TESTS |
10 |
640 |
79462400 |
|
|
272855552 |
TeCkZZa |
C |
July 26, 2024, 5:43 p.m. |
OK |
Java 21 |
TESTS |
10 |
640 |
79462400 |
|
|
272907900 |
vikash_45 |
C |
July 27, 2024, 5:22 a.m. |
OK |
Java 21 |
TESTS |
10 |
640 |
83353600 |
|
|
272858274 |
testtest111ksjfrdvn |
C |
July 26, 2024, 6:02 p.m. |
OK |
Java 21 |
TESTS |
10 |
656 |
79872000 |
|
|
272858413 |
testtest111ksjfrdvn |
C |
July 26, 2024, 6:03 p.m. |
OK |
Java 21 |
TESTS |
10 |
656 |
80793600 |
|
|
272883301 |
gdax |
C |
July 27, 2024, 12:03 a.m. |
OK |
Java 21 |
TESTS |
10 |
686 |
81510400 |
|
|
272873501 |
Devashish025 |
C |
July 26, 2024, 8:43 p.m. |
OK |
Java 21 |
TESTS |
10 |
702 |
84889600 |
|
|
272861642 |
6AhmedReda9 |
C |
July 26, 2024, 6:27 p.m. |
OK |
Java 21 |
TESTS |
10 |
717 |
78643200 |
|
|
272867409 |
polsage |
C |
July 26, 2024, 7:25 p.m. |
OK |
Java 21 |
TESTS |
10 |
718 |
83763200 |
|
|
272889979 |
BlizGale |
C |
July 27, 2024, 2:08 a.m. |
OK |
Java 8 |
TESTS |
10 |
514 |
77107200 |
|
|
272871778 |
suraj1771singh |
C |
July 26, 2024, 8:20 p.m. |
OK |
Java 8 |
TESTS |
10 |
515 |
71475200 |
|
|
272862074 |
karnrahul786 |
C |
July 26, 2024, 6:31 p.m. |
OK |
Java 8 |
TESTS |
10 |
561 |
153600000 |
|
|
272866516 |
CipherSphinx_Raj |
C |
July 26, 2024, 7:15 p.m. |
OK |
Java 8 |
TESTS |
10 |
578 |
153804800 |
|
|
272910213 |
agcwha2567 |
C |
July 27, 2024, 5:42 a.m. |
OK |
Java 8 |
TESTS |
10 |
859 |
35737600 |
|
|
272911321 |
KONGO11 |
C |
July 27, 2024, 5:51 a.m. |
OK |
Java 8 |
TESTS |
10 |
952 |
71475200 |
|
|
272861986 |
ss_0 |
C |
July 26, 2024, 6:30 p.m. |
OK |
Java 8 |
TESTS |
10 |
1249 |
94515200 |
|
|
272898347 |
rujuldwivedi |
C |
July 27, 2024, 3:43 a.m. |
OK |
Java 8 |
TESTS |
10 |
1359 |
26828800 |
|
|
272850346 |
sandesh543 |
C |
July 26, 2024, 5:04 p.m. |
OK |
Java 8 |
TESTS |
10 |
1452 |
79257600 |
|
|
272877134 |
Mr_A |
C |
July 26, 2024, 9:43 p.m. |
OK |
Java 8 |
TESTS |
10 |
1468 |
79257600 |
|
|
272885538 |
blkrop |
C |
July 27, 2024, 12:56 a.m. |
OK |
Kotlin 1.9 |
TESTS |
10 |
780 |
80179200 |
|
|
272885249 |
blkrop |
C |
July 27, 2024, 12:50 a.m. |
OK |
Kotlin 1.9 |
TESTS |
10 |
1374 |
135270400 |
|
|
272885118 |
blkrop |
C |
July 27, 2024, 12:47 a.m. |
OK |
Kotlin 1.9 |
TESTS |
10 |
1671 |
136294400 |
|
|
272884900 |
blkrop |
C |
July 27, 2024, 12:42 a.m. |
OK |
Kotlin 1.9 |
TESTS |
10 |
1828 |
133222400 |
|
|
272867107 |
Martinien_ENSAF |
C |
July 26, 2024, 7:22 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
1015 |
122880000 |
|
|
272894678 |
nealzane |
C |
July 27, 2024, 3:03 a.m. |
OK |
PyPy 3 |
TESTS |
10 |
1062 |
78131200 |
|
|
272856326 |
Ysb04 |
C |
July 26, 2024, 5:49 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
1171 |
78848000 |
|
|
272853660 |
nsut739824 |
C |
July 26, 2024, 5:34 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
2296 |
97792000 |
|
|
272858316 |
MdNazmulHossain |
C |
July 26, 2024, 6:02 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
2406 |
75878400 |
|
|
272855033 |
mitelfrend |
C |
July 26, 2024, 5:40 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
2421 |
97689600 |
|
|
272853565 |
gh0ul__ |
C |
July 26, 2024, 5:33 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
2452 |
114380800 |
|
|
272907732 |
poseidontom |
C |
July 27, 2024, 5:21 a.m. |
OK |
PyPy 3 |
TESTS |
10 |
2483 |
73932800 |
|
|
272865846 |
RatanPrakash |
C |
July 26, 2024, 7:08 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
4812 |
215961600 |
|
|
272895548 |
Sunlight |
C |
July 27, 2024, 3:13 a.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
593 |
20070400 |
|
|
272854752 |
sarvajnya_18 |
C |
July 26, 2024, 5:38 p.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
718 |
67584000 |
|
|
272866381 |
arady3337 |
C |
July 26, 2024, 7:14 p.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
749 |
168140800 |
|
|
272904507 |
yer_06 |
C |
July 27, 2024, 4:51 a.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
796 |
135168000 |
|
|
272905068 |
alexwice |
C |
July 27, 2024, 4:57 a.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
811 |
157081600 |
|
|
272852119 |
Om_Singh_ |
C |
July 26, 2024, 5:27 p.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
827 |
141209600 |
|
|
272895922 |
Sxuyang |
C |
July 27, 2024, 3:16 a.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
842 |
136908800 |
|
|
272873433 |
lls_ |
C |
July 26, 2024, 8:42 p.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
843 |
162099200 |
|
|
272872036 |
ErmiCodeforce |
C |
July 26, 2024, 8:23 p.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
874 |
135475200 |
|
|
272908043 |
N1664 |
C |
July 27, 2024, 5:24 a.m. |
OK |
PyPy 3-64 |
TESTS |
10 |
874 |
147558400 |
|
|
272906430 |
def337485 |
C |
July 27, 2024, 5:09 a.m. |
OK |
Python 3 |
TESTS |
10 |
3171 |
64921600 |
|
|
272899575 |
eugalt |
C |
July 27, 2024, 3:56 a.m. |
OK |
Python 3 |
TESTS |
10 |
3343 |
66457600 |
|
|
272894970 |
def337485 |
C |
July 27, 2024, 3:07 a.m. |
OK |
Python 3 |
TESTS |
10 |
3671 |
65024000 |
|
|
272904704 |
Qwerty8199 |
C |
July 27, 2024, 4:54 a.m. |
OK |
Python 3 |
TESTS |
10 |
3858 |
175206400 |
|
|
272895605 |
siister6832 |
C |
July 27, 2024, 3:13 a.m. |
OK |
Python 3 |
TESTS |
10 |
4155 |
175718400 |
|
|
272893937 |
bunny_2702 |
C |
July 27, 2024, 2:55 a.m. |
OK |
Python 3 |
TESTS |
10 |
4593 |
194457600 |
|
|
272849328 |
SubhashChandra_26 |
C |
July 26, 2024, 5:03 p.m. |
OK |
Python 3 |
TESTS |
10 |
4639 |
165580800 |
|
|
272849323 |
Avinash_1_jha |
C |
July 26, 2024, 5:03 p.m. |
OK |
Python 3 |
TESTS |
10 |
4656 |
182169600 |
|
|
272912255 |
devjain1028 |
C |
July 27, 2024, 5:59 a.m. |
OK |
Python 3 |
TESTS |
10 |
4671 |
160768000 |
|
|
272906434 |
jokeeee |
C |
July 27, 2024, 5:09 a.m. |
OK |
Python 3 |
TESTS |
10 |
4734 |
129740800 |
|
|
272859536 |
n685 |
C |
July 26, 2024, 6:11 p.m. |
OK |
Rust 2021 |
TESTS |
10 |
187 |
22323200 |
|
|
272849029 |
Kerplunk |
C |
July 26, 2024, 5:02 p.m. |
OK |
Rust 2021 |
TESTS |
10 |
249 |
60723200 |
|
|
272849643 |
zebracobra |
C |
July 26, 2024, 5:03 p.m. |
OK |
Rust 2021 |
TESTS |
10 |
562 |
53452800 |
|
|
272878148 |
Moad101 |
C |
July 26, 2024, 10:01 p.m. |
OK |
Rust 2021 |
TESTS |
10 |
562 |
55500800 |
|
|
remove filters
Back to search problems