dorasainath955's blog

By dorasainath955, history, 5 weeks ago, In English

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"
  • Vote: I like it
  • +5
  • Vote: I do not like it

»
5 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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

»
5 weeks ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

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