답안 #563493

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
563493 2022-05-17T10:40:44 Z shahriarkhan 사육제 (CEOI14_carnival) C++14
100 / 100
20 ms 312 KB
#include<bits/stdc++.h>
using namespace std ;

const int MX = 155 ;

int col[MX] , vis[MX] , cnt[MX] , cur ;

vector<int> adj[MX] ;

int query(int l , int r)
{
    printf("%d ",r-l+1) ;
    for(int i = l ; i <= r ; ++i)
    {
        printf("%d ",i) ;
    }
    printf("\n") ;
    fflush(stdout) ;
    int ret ;
    scanf("%d",&ret) ;
    return ret ;
}

void dfs(int s)
{
    if(vis[s]) return ;
    vis[s] = 1 , col[s] = cur ;
    for(int t : adj[s])
    {
        dfs(t) ;
    }
}

int main()
{
    int n ;
    scanf("%d",&n) ;
    for(int i = 1 ; i <= n ; ++i)
    {
        cnt[i] = query(1,i) ;
        if(cnt[i]!=cnt[i-1]) continue ;
        int low = 1 , high = i - 1 ;
        while(low<high)
        {
            int mid = (low+high+1)>>1 ;
            if(query(mid,i)==query(mid,i-1)) low = mid ;
            else high = mid - 1 ;
        }
        adj[low].push_back(i) ;
    }
    for(int i = 1 ; i <= n ; ++i)
    {
        if(!vis[i])
        {
            ++cur ;
            dfs(i) ;
        }
    }
    printf("0 ") ;
    for(int i = 1 ; i <= n ; ++i)
    {
        printf("%d ",col[i]) ;
    }
    printf("\n") ;
    fflush(stdout) ;
    return 0 ;
}

Compilation message

carnival.cpp: In function 'int query(int, int)':
carnival.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     scanf("%d",&ret) ;
      |     ~~~~~^~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     scanf("%d",&n) ;
      |     ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 312 KB Output is correct
2 Correct 15 ms 208 KB Output is correct
3 Correct 7 ms 208 KB Output is correct
4 Correct 4 ms 208 KB Output is correct
5 Correct 16 ms 208 KB Output is correct
6 Correct 16 ms 208 KB Output is correct
7 Correct 11 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 312 KB Output is correct
2 Correct 16 ms 208 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 5 ms 208 KB Output is correct
5 Correct 17 ms 308 KB Output is correct
6 Correct 16 ms 304 KB Output is correct
7 Correct 18 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 304 KB Output is correct
2 Correct 15 ms 304 KB Output is correct
3 Correct 16 ms 208 KB Output is correct
4 Correct 4 ms 208 KB Output is correct
5 Correct 12 ms 208 KB Output is correct
6 Correct 17 ms 208 KB Output is correct
7 Correct 11 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 308 KB Output is correct
2 Correct 20 ms 308 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 4 ms 208 KB Output is correct
5 Correct 13 ms 208 KB Output is correct
6 Correct 9 ms 208 KB Output is correct
7 Correct 14 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 208 KB Output is correct
2 Correct 17 ms 208 KB Output is correct
3 Correct 11 ms 208 KB Output is correct
4 Correct 10 ms 208 KB Output is correct
5 Correct 7 ms 300 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 4 ms 208 KB Output is correct