Submission #586110

#TimeUsernameProblemLanguageResultExecution timeMemory
586110rzirvi1665Carnival (CEOI14_carnival)C++14
0 / 100
19 ms208 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; const int MN=1e5+10; const int MOD=1e9+7; using pi = pair<ll, ll>; using ti = tuple<ll, ll, ll>; typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set; #define pb push_back #define mp make_pair #define mt make_tuple #define MAX LLONG_MAX #define MIN LLONG_MIN #define MAX_SIZE 1000005 #define lcm(a, b) (a*b)/__gcd(a, b) ll query(ll l, ll r){ cout<<r-l+1<<" "; for (int i=l; i<=r; i++){ cout<<i<<" "; } cout<<endl; ll num; cin>>num; return num; } bool f(ll x){ // binary search check (greedy) } ll binaryMin(ll low, ll high, ll end){ // for min ll res=0; while (low<=high){ ll mid=(low+high)/2; if (query(mid, end)>query(mid, end-1)){ res=mid-1; high=mid-1; } else{ low=mid+1; } } return res; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); ll n; cin>>n; ll prev=0; ll index=1; ll type[n+1]={0}; for (int i=1; i<=n; i++){ ll diff=query(1, i); if (diff>prev){ type[i]=index; index++; } else{ ll pos=binaryMin(1, i-1, i); type[i]=type[pos]; } prev=diff; } cout<<0<<" "; for (int i=1; i<=n; i++){ cout<<type[i]<<" "; } cout<<endl; }

Compilation message (stderr)

carnival.cpp: In function 'bool f(ll)':
carnival.cpp:35:1: warning: no return statement in function returning non-void [-Wreturn-type]
   35 | }
      | ^
#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...