Submission #586112

# Submission time Handle Problem Language Result Execution time Memory
586112 2022-06-29T22:50:36 Z rzirvi1665 Carnival (CEOI14_carnival) C++14
100 / 100
19 ms 208 KB
#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{
            if (i>1 && query(i-1, i)==1){
                type[i]=type[i-1];
            }
            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

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 time Memory Grader output
1 Correct 19 ms 208 KB Output is correct
2 Correct 16 ms 208 KB Output is correct
3 Correct 7 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 11 ms 208 KB Output is correct
6 Correct 4 ms 208 KB Output is correct
7 Correct 15 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 208 KB Output is correct
2 Correct 18 ms 208 KB Output is correct
3 Correct 5 ms 208 KB Output is correct
4 Correct 5 ms 208 KB Output is correct
5 Correct 13 ms 208 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 14 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 208 KB Output is correct
2 Correct 17 ms 208 KB Output is correct
3 Correct 14 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 12 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 208 KB Output is correct
2 Correct 9 ms 208 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 11 ms 208 KB Output is correct
6 Correct 7 ms 208 KB Output is correct
7 Correct 14 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 208 KB Output is correct
2 Correct 18 ms 208 KB Output is correct
3 Correct 16 ms 208 KB Output is correct
4 Correct 12 ms 208 KB Output is correct
5 Correct 10 ms 208 KB Output is correct
6 Correct 8 ms 208 KB Output is correct
7 Correct 5 ms 208 KB Output is correct