답안 #599882

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
599882 2022-07-20T05:49:12 Z AryamanRtunjay 사육제 (CEOI14_carnival) Java 11
0 / 100
330 ms 14828 KB
	import java.util.*;

public class carnival 
{
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);

        List<Integer> unique = new ArrayList<>();
        List<Integer> all = new ArrayList<>();
        List<Integer> notUnique = new ArrayList<>();

        List<Integer> costumeNums = new ArrayList<>();

        int N = sc.nextInt();
        for(int i = 0; i < N; i++)
        {
            unique.add(i + 1);
            all.add(i + 1);
            String uniqueAsStr = unique.toString();
            uniqueAsStr = uniqueAsStr.substring(1, uniqueAsStr.length() - 1);

            uniqueAsStr = uniqueAsStr.replace(",", "");

            System.out.println(unique.size() + " " + uniqueAsStr);
            int numUnique = sc.nextInt();

            if(numUnique != unique.size())
            {
                unique.remove(unique.size() - 1);
                notUnique.add(i + 1);
            }
        }

        for(int i = 0; i < N; i++)
        {
            costumeNums.add(0);
        }

        for(int i = 0; i < unique.size(); i++)
        {
            costumeNums.set(unique.get(i) - 1, i + 1);
        }

        for(int i = 0; i < notUnique.size(); i++)
        {
            int top = unique.size() - 1;
            int bottom = 0;
            int idx = 0;

            while(top >= bottom)
            {
                idx = (top + bottom)/2;

                List<Integer> checkList = unique.subList(bottom, idx + 1);
                String checkListStr = checkList.toString();
                checkListStr = checkListStr.substring(1, checkListStr.length() - 1);
                checkListStr = checkListStr.replace(",", "");

                System.out.println(checkList.size() + 1 + " " + checkListStr + " " + notUnique.get(i));

                int numUnique = sc.nextInt();
                if(numUnique != checkList.size() + 1)
                {
                    if(checkList.size() == 1)
                    {
                        costumeNums.set(notUnique.get(i) - 1, costumeNums.get(checkList.get(0) - 1));
                        break;
                    }
                    top = idx;
                }
                else
                {
                    bottom = idx + 1;
                    if(checkList.size() == 1)
                    {
                        top = bottom + 2;
                    }
                }
            }
        }

        String out = costumeNums.toString();
        out = out.substring(1, out.length() - 1);
        out = "0 " + out;
        out = out.replace(",", "");
        System.out.println(out);
    }
}

class Pair
{
    public int first;
    public int second;
    
    public Pair(int first, int second)
    {
        this.first = first;
        this.second = second;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 330 ms 14828 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 279 ms 14292 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 306 ms 14176 KB Output is correct
2 Runtime error 289 ms 14432 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 286 ms 14140 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 268 ms 14152 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -