Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

 
 
 
 
General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
138843789 Practice:
andreyDagger
1608C - 18 PyPy 3-64 Accepted 654 ms 26176 KB 2021-12-12 12:32:47 2021-12-12 12:32:47
→ Source
def solve():
    n = int(input())
    players = [0] * n
    ans = [0] * n
    dp = [0] * n
    pref = [0] * n
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    for i in range(n):
        players[i] = [a[i], b[i], i]
    players.sort()
    pref[0] = players[0][1]
    for i in range(1, n):
        pref[i] = max(pref[i - 1], players[i][1])
    mn = players[n - 1][1]
    dp[n - 1] = 1
    for i in range(n - 2, -1, -1):
        if pref[i] > mn:
            dp[i] = 1
            mn = min(mn, players[i][1])
    for i in range(n):
        ans[players[i][2]] = dp[i]
    for i in range(n):
        print(ans[i], end='')
    print()


for _ in range(int(input())):
    solve()
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details