Блог пользователя dorasainath955

Автор dorasainath955, история, 7 недель назад, По-английски

Submission
C1. Adjust The Presentation (Easy Version)

Approach: Assume that answer is "YA" and try to contradict it, if contradicted print "TIDAK"


  1. create a unique vector that consists of elements of "b" in such a way that no two consecutive elements are repeating
    b = {1, 1, 2, 2, 3} unqiue = {1, 2, 3}
  2. create a map mp that stores whether a element element has already occured(useful to verify if the slide encountered, bi can be given by person with same as bi).
    eg: b = {1, 2, 2, 1}, a = {1, 2, 3}, since person-1 and person-2 can give slide-1, 2. Then again we encountered slide-1 at b[3](zero index) so person-1(he's visited it) can be rearranged into giving slide-1 at b[3], map stores this information
    • Iterate through all elements of unique if the index i goes out of bounds for array a then break the loop;
    • if you find a[i] != b[i] && mp[unique[i]]==false then we can't arrange the persons in array to get our element bi print "TIDAK"
  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

»
7 недель назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

1

4 6 0

1 2 3 4

1 2 1 2 4 3

answer should be TIDAK you can't just stop when the index goes out of bound of a

»
7 недель назад, # |
Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

Update: The above approach will fail test case of this form
1
5 6 0
1 2 3 1 4
1 2 1 2 4 2