Submission #918543

# Submission time Handle Problem Language Result Execution time Memory
918543 2024-01-30T06:25:53 Z Fikrat_Asadzadeh Carnival (CEOI14_carnival) C++14
0 / 100
1 ms 952 KB
#include <bits/stdc++.h> 
using namespace std; 
typedef unsigned long long ull; 
#define ll long long
typedef vector < int > vl; 
typedef set < int > setl;
#define F first
#define S second    
#define all(v) v.begin(), v.end() 
#define pll pair < int , int > 
#define db  double
#define nll cout << "\n"
#define nl endl
#define sync                          \
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0) ;
const int MAX = 1e6 + 5; 
const long long inf = 1e18; 
map < vl, ll> mp;
ll n, a[MAX], k;
ll ask(vl &v){
    if(mp[v])return mp[v];
    cout << v.size() << " ";
    for(auto i : v){
        cout << i << " ";
    }
    nll;
    ll x;
    cin >> x;
    return mp[v] = x;
}
void solve(){
    vl v;
    cin >> n;
    ll x;
    for(ll i = 1; i <= n; i++){
        v.push_back(i);
        k = ask(v);
        if(k > x)a[i] = k, x = k; 
        else{
            v.pop_back();
            ll l = 0, r = v.size() - 1, res = -1;
            while(l < r){
                ll mid = (l + r) >> 1;
                vl cur;
                for(ll i = 0; i <= mid; i++){
                    cur.push_back(v[i]);
                }
                k = ask(cur);
                cur.push_back(v[i]);
                ll cur2 = ask(cur);
                if(cur2 == k){
                    r = mid;
                }
                else l = mid + 1;
            }
            a[i] = a[v[l]];
        }
    }
    cout << "0 ";
    for(ll i = 1; i <= n; i++)cout << a[i] << " ";
}
signed main(){
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

Compilation message

carnival.cpp: In function 'void solve()':
carnival.cpp:41:41: warning: unused variable 'res' [-Wunused-variable]
   41 |             ll l = 0, r = v.size() - 1, res = -1;
      |                                         ^~~
carnival.cpp:38:9: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   38 |         if(k > x)a[i] = k, x = k;
      |         ^~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 440 KB Integer 0 violates the range [1, 11]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 444 KB Integer 0 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 440 KB Integer 0 violates the range [1, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 952 KB Integer 0 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 700 KB Integer 0 violates the range [1, 2]
2 Halted 0 ms 0 KB -