Codeforces Round 796 (Div. 1)

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.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
1687 Codeforces Round 796 (Div. 1) FINISHED False 7200 82999463 June 3, 2022, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 1494 ) C Sanae and Giant Robot PROGRAMMING brute force constructive algorithms data structures dfs and similar ds

B'The state of a robot can be represented by an array of integers of length n . Initially, the robot is at state a . She wishes to turn it into state b . As a great programmer, Sanae knows the art of copy-and-paste. In one operation, she can choose some segment from given segments, copy the segment from b and paste it into the same place of the robot, replacing the original state there. However, she has to ensure that the sum of a does not change after each copy operation in case the robot go haywire. Formally, Sanae can choose segment [l,r] and assign a_i = b_i ( l <= i <= r ) if sum limits_{i=1}^n a_i does not change after the operation. Determine whether it is possible for Sanae to successfully turn the robot from the initial state a to the desired state b with any (possibly, zero) operations. Each test contains multiple test cases. The first line contains a single integer t ( 1 <= q t <= q 2 cdot 10^4 ) -- the number of test cases. The descriptions of the test cases follow. The first line of each test case contains two integers n , m ( 2 <= q n <= q 2 cdot 10^5 , 1 <= q m <= q 2 cdot 10^5 ) -- the length of a , b and the number of segments. The second line contains n intergers a_1,a_2, ldots,a_n ( 1 <= q a_i <= q 10^9 ) -- the initial state a . The third line contains n intergers b_1,b_2, ldots,b_n ( 1 <= q b_i <= q 10^9 ) -- the desired state b . Then m lines follow, the i -th line contains two intergers l_i,r_i ( 1 <= q l_i < r_i <= q n ) -- the segments that can be copy-pasted by Sanae. It is guaranteed that both the sum of n and the sum of m over all test cases does not exceed 2 cdot 10 ^ 5 . For each test case, print "YES" (without quotes) if a can be turned into b , or "NO" (without quotes) otherwise. You can output "YES" and "NO" in any case (for examp'...

Tutorials

Editorial of Codeforces Round 796

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
159404326 mban259 C June 3, 2022, 4:10 p.m. OK C# 10 TESTS 30 561 49766400

remove filters

Back to search problems