# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
563493 | shahriarkhan | Carnival (CEOI14_carnival) | C++14 | 20 ms | 312 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |