Dancing Pokemon(CJ01) Editorial

Can someone provide me with editorial of this problem


Thanks in advance

The simplest solution would be by using STL-MAPS. We just have to check if the number has occurred before or not.

Create a map with an integer and a boolean value.
Just insert into the map all the poke-ids with boolean value 1(true).

Next just check if the next pokemon is already in the map.
If YES, output “YES”, else output “NO” and insert it into the map with true.

Complexity:- O(N.Log(N))

Other solution could be simply to use binary trees.

you can use set to do this question see my solution here link texthttps://www.codechef.com/viewsolution/11219412

Hello chefs :slight_smile:
I’m new to codechef and also the beginner to the programming :slight_smile:
My solution to this problem is


import java.util.*;
public class Main {
            public static void main(String args[]) {
                    ArrayList <Integer> partyattendersid;
                    partyattendersid = new ArrayList <Integer>();
                    Scanner scanner = new Scanner(System.in);
                    int T;
                    T = scanner.nextInt();
                    for(int i=0;i<T;i++) {
                            int N,Q,id;
                            N = scanner.nextInt();
                            Q = scanner.nextInt();
                            for(int j=0;j<N;j++) {
                                    id = scanner.nextInt();
                                    if(partyattendersid.indexOf(id) != -1);
                                    else partyattendersid.add(id);
                            }
                            int qid[] = new int[Q];
                            for(int j=0;j<Q;j++)
                            qid[j] = scanner.nextInt();
                            for(int j=0;j<Q;j++) {
                                    if(partyattendersid.indexOf(qid[j]) == -1) {
                                            System.out.println("NO");
                                            partyattendersid.add(qid[j]);
                                    }
                                    else System.out.println("YES");
                            }
                    }
                 }
}
     

I have tested my code in my system I’m getting the correct answer, but I submit to codechef I’m getting the wrong answer :frowning: please help me… Any error in my code??? Thanks in advance :slight_smile:

please help me to find error https://www.codechef.com/viewsolution/11157449