답안 #436635

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
436635 2021-06-24T17:17:57 Z mnair797 사육제 (CEOI14_carnival) Java 11
100 / 100
429 ms 13832 KB
import java.io.*;
import java.util.*;
 
public class carnival {
 
    public static void main(String[] args) throws IOException {
    	
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
 
        int N = Integer.parseInt(reader.readLine()); 
 
        int[] groups = new int[N + 1];
        groups[1] = 1;
 
        int groupCount = 1;
        int[] groupMainPoint = new int[N + 1];
 
        groupMainPoint[groupCount] = 1;
 
        String startQuery = "1";
        int prev = 1;
 
        for(int i = 2; i <= N; i++){
            startQuery += " " + String.valueOf(i);
            System.out.println(i + " " + startQuery);
            System.out.flush();
 
            int newGroups = Integer.parseInt(reader.readLine());
            if(newGroups != prev){
                groupCount++;
                groups[i] = groupCount;
                groupMainPoint[groupCount] = i;
            } else {
                int a = 1;
                int b = groupCount;
                while(a != b){
                    int mid = (a + b) / 2;
                    String query = "";
                    for (int j = a; j <= mid; j++){
                        query += " " + String.valueOf(groupMainPoint[j]);
                    }
                    query += " " + i;
                    System.out.println(String.valueOf(mid - a + 2) + query);
                    System.out.flush();
 
                    int currGroupCount = Integer.parseInt(reader.readLine());
                    if(currGroupCount == (mid - a + 2)){
                        a = mid + 1;
                    } else {
                        b = mid;
                    }
                }
 
                groups[i] = a;
            }
 
            prev = newGroups;
        }
        
        String ans = "0";
        for(int i = 1; i <= N; i++){
            ans += " " + String.valueOf(groups[i]);
        }
        System.out.println(ans);
        System.out.flush();
        return;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 385 ms 13832 KB Output is correct
2 Correct 422 ms 13632 KB Output is correct
3 Correct 380 ms 13556 KB Output is correct
4 Correct 341 ms 13424 KB Output is correct
5 Correct 368 ms 13500 KB Output is correct
6 Correct 341 ms 13380 KB Output is correct
7 Correct 400 ms 13448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 374 ms 13300 KB Output is correct
2 Correct 415 ms 13436 KB Output is correct
3 Correct 370 ms 13412 KB Output is correct
4 Correct 341 ms 13488 KB Output is correct
5 Correct 388 ms 13480 KB Output is correct
6 Correct 379 ms 13468 KB Output is correct
7 Correct 391 ms 13524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 216 ms 11712 KB Output is correct
2 Correct 370 ms 13396 KB Output is correct
3 Correct 429 ms 13444 KB Output is correct
4 Correct 332 ms 13360 KB Output is correct
5 Correct 378 ms 13420 KB Output is correct
6 Correct 400 ms 13536 KB Output is correct
7 Correct 405 ms 13508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 353 ms 13288 KB Output is correct
2 Correct 369 ms 13476 KB Output is correct
3 Correct 371 ms 13588 KB Output is correct
4 Correct 330 ms 13616 KB Output is correct
5 Correct 412 ms 13304 KB Output is correct
6 Correct 415 ms 13444 KB Output is correct
7 Correct 417 ms 13440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 339 ms 13536 KB Output is correct
2 Correct 398 ms 13480 KB Output is correct
3 Correct 400 ms 13568 KB Output is correct
4 Correct 392 ms 13288 KB Output is correct
5 Correct 388 ms 13528 KB Output is correct
6 Correct 375 ms 13380 KB Output is correct
7 Correct 347 ms 13392 KB Output is correct