0% found this document useful (0 votes)
50 views2 pages

Problem - 2092B - Codeforces

Uploaded by

Yhlas Yklymow
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views2 pages

Problem - 2092B - Codeforces

Uploaded by

Yhlas Yklymow
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

9/2/25, 10:26 AM Problem - 2092B - Codeforces

|
stdfloat | Logout

HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN

PROBLEMS SUBMIT STATUS STANDINGS CUSTOM TEST

Codeforces Round 1014 (Div. 2)


B. Lady Bug Finished
time limit per test: 1 second Practice
memory limit per test: 256 megabytes

As soon as Dasha Purova crossed the border of France, the villain Markaron kidnapped her and placed her in a
prison under his large castle. Fortunately, the wonderful Lady Bug, upon hearing the news about Dasha,
immediately ran to save her in Markaron's castle. However, to get there, she needs to crack a complex password. → Virtual participation 
Virtual contest is a way to take part in past contest,
The password consists of two bit strings a and b, each of which has a length of n . In one operation, Lady Bug can as close as possible to participation on time. It is
choose any index 2 ≤ i ≤ n and perform one of the following actions: supported only ICPC mode for virtual contests. If
you've seen these problems, a virtual contest is not
for you - solve these problems in the archive. If you
1. swap(ai , bi−1 ) (swap the values of ai and bi−1 ), or just want to solve some problem from a contest, a
virtual contest is not for you - solve this problem in
2. swap(bi , ai−1 ) (swap the values of bi and ai−1 ). the archive. Never use someone else's code, read
the tutorials or communicate with other person
during a virtual contest.
Lady Bug can perform any number of operations. The password is considered cracked if she can ensure that the
first string consists only of zeros. Help her understand whether or not she will be able to save the unfortunate Start virtual contest
Dasha.

Input → Clone Contest to Mashup 


4
Each test consists of several test cases. The first line of the input data contains one integer t (1 ≤ t ≤ 10 ) — the
number of test cases. The description of the test cases follows.
→ Submit?
5
The first line of each test case contains one integer n (2 ≤ n ≤ 2 ⋅ 10 ) — the length of the bit strings of the
password. Language: GNU G++20 13.2 (64 bit, winlibs)

The next two lines contain the bit strings of length n , a and b, which represent the password. Each of the strings Choose
Choose File No file chosen
file:
contains only the characters 0 and '1'.
Submit
5
It is guaranteed that the sum of n across all test cases does not exceed 2 ⋅ 10 .

Output
For each test case, output "YES" if Lady Bug can crack the password after any number of operations; otherwise, → Contest materials
output "NO".
Announcement (en)
You can output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", Tutorial (en)
and "YES" will be accepted as a positive answer.

Example
→ CF GetRating
input Copy
*1000
4
3
Show All Tags
000
000 Contest Standings
6
010001
010111
5
10000
01010
2
11
00

output Copy

YES
YES
NO
YES

Note
In the first test case, the string a immediately consists only of zeros.

In the second test case, a possible sequence of operations is:

1. swap(a2 , b1 )

010001

010111

2. swap(b5 , a4 )

000001

110111

https://codeforces.com/problemset/problem/2092/B 1/2
9/2/25, 10:26 AM Problem - 2092B - Codeforces

3. swap(a4 , b3 )

000101

110101

4. swap(a5 , b4 )

000001

111101

Codeforces (c) Copyright 2010-2025 Mike Mirzayanov


The only programming contests Web 2.0 platform
Server time: Sep/02/2025 10:24:45UTC+5 (h1).
Desktop version, switch to mobile version.
Privacy Policy | Terms and Conditions

Supported by

https://codeforces.com/problemset/problem/2092/B 2/2

You might also like