Submission #563483

# Submission time Handle Problem Language Result Execution time Memory
563483 2022-05-17T10:15:37 Z shahriarkhan Carnival (CEOI14_carnival) C++14
0 / 100
13 ms 304 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)<(i-mid+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) ;
      |     ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 296 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 292 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 304 KB Output is correct
2 Incorrect 10 ms 208 KB Incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 296 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -