String Sorted
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Time Limit: 1.0 s
Memory Limit: 256.0 MB
Description
You are given two strings S and P; the length of both strings is equal, which is N.
You can perform the following operations as many times as you wish:
- Choose an index \(i\), \(1<=i<=N\), and swap their characters.(Ex. swap (\(S[i] , P[i]\)) )
Your goal is to make at least one of the strings sorted.
string "abc" and "bbbpp" are sorted, while string "babc", "zaab" are not.
Input
First line T, the number of test cases.
In each test case, First line N, the length of the both strings.
Second line, a string S.
Third line, a string P.
\(1<=T<=10^4\)
\(1<=N<=10^5\)
String S and P contains only lowercase english alphabets.
Sum of N overall test case doesn't exceed \(10^5\).
Output
In each test case, print Yes ,if one of the strings make sorted, otherwise pirnt No.
Sample
Input | Output |
---|---|
|
|
First test case,
String S = "pcc" and P = "acb",
Choose index 1, and swap their character.
After swap, String S = "acc" and P = "pcb".
string S is sorted.
Lockout contest round-1 ( Mazharul Islam vs Thakur Emon)
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 4
- Start at
- 2024-11-04 17:00
- End at
- 2024-11-04 18:00
- Duration
- 1.0 hour(s)
- Host
- Partic.
- 2