Submission #563493

#TimeUsernameProblemLanguageResultExecution timeMemory
563493shahriarkhanCarnival (CEOI14_carnival)C++14
100 / 100
20 ms312 KiB
#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)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...