Submission #918048

# Submission time Handle Problem Language Result Execution time Memory
918048 2024-01-29T12:51:51 Z vjudge1 Carnival (CEOI14_carnival) C++17
100 / 100
8 ms 724 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
/* DEFINES */
#define S second
#define F first
#define ll long long
#define ull unsigned long long
#define ld long double
#define npos ULLONG_MAX
#define INF LLONG_MAX
#define vv(a) vector<a>
#define pp(a, b) pair<a, b>
#define pq(a) priority_queue<a>
#define qq(a) queue<a>
#define ss(a) set<a>
#define mm(a, b) map<a, b>
#define ump(a, b) unordered_map<a, b>
#define ANDROID                   \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define elif else if
#define endl "\n"
#define allc(a) begin(a), end(a)
#define all(a) a, a + sizeof(a) / sizeof(a[0])
#define pb push_back
#define logi(a) __lg(a)
#define sqrt(a) sqrtl(a)
#define mpr make_pair
#define ins insert
using namespace std;
using namespace __gnu_pbds;
using namespace __cxx11;
typedef char chr;
typedef basic_string<chr> str;
template <typename T, typename key = less<T>>
using ordered_set = tree<T, null_type, key, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll ask(vv(ll) &v)
{
    cout << v.size() << " ";
    for (ll i = 0; i < v.size(); i++)
        cout << v[i] << " \n"[i == v.size() - 1];
    cout << flush;
    ll ans;
    cin >> ans;
    return ans;
}
void answer(vv(ll) &v)
{
    cout << "0 ";
    for (ll i = 0; i < v.size(); i++)
        cout << v[i] << " \n"[i == v.size() - 1];
    cout << flush;
}
void solve()
{
    ll n;
    cin >> n;
    vv(ll) tmp, ans(n), cur;
    for (ll i = 1; i <= n; i++)
    {
        ll l = 0, r = (ll)cur.size() - 1, res = cur.size() + 1;
        while (l <= r)
        {
            ll mid = (l + r) >> 1;
            tmp.clear();
            for (ll j = 0; j <= mid; j++)
                tmp.pb(cur[j]);
            tmp.pb(i);
            if (ask(tmp) == mid + 1)
                r = mid - 1, res = mid + 1;
            else
                l = mid + 1;
        } 
        if (res == cur.size() + 1)
            cur.pb(i);
        ans[i - 1] = res;
    }
    answer(ans);
}
/*
 
*/
int main()
{
    ANDROID
    // precomp();
    ll t = 1;
    // cin >> t;
    for (ll i = 1; i <= t; i++)
        // cout << "Case #" << i << ": ",
        solve();
    cerr << "\nTime elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n";
}

Compilation message

carnival.cpp: In function 'long long int ask(std::vector<long long int>&)':
carnival.cpp:47:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for (ll i = 0; i < v.size(); i++)
      |                    ~~^~~~~~~~~~
carnival.cpp:48:33: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         cout << v[i] << " \n"[i == v.size() - 1];
      |                               ~~^~~~~~~~~~~~~~~
carnival.cpp: In function 'void answer(std::vector<long long int>&)':
carnival.cpp:57:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for (ll i = 0; i < v.size(); i++)
      |                    ~~^~~~~~~~~~
carnival.cpp:58:33: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |         cout << v[i] << " \n"[i == v.size() - 1];
      |                               ~~^~~~~~~~~~~~~~~
carnival.cpp: In function 'void solve()':
carnival.cpp:81:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |         if (res == cur.size() + 1)
      |             ~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 460 KB Output is correct
2 Correct 3 ms 716 KB Output is correct
3 Correct 5 ms 712 KB Output is correct
4 Correct 6 ms 708 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 3 ms 708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 3 ms 724 KB Output is correct
3 Correct 3 ms 456 KB Output is correct
4 Correct 6 ms 456 KB Output is correct
5 Correct 2 ms 456 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 2 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 448 KB Output is correct
2 Correct 2 ms 456 KB Output is correct
3 Correct 4 ms 712 KB Output is correct
4 Correct 8 ms 460 KB Output is correct
5 Correct 3 ms 712 KB Output is correct
6 Correct 3 ms 712 KB Output is correct
7 Correct 4 ms 712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 452 KB Output is correct
2 Correct 2 ms 452 KB Output is correct
3 Correct 6 ms 456 KB Output is correct
4 Correct 7 ms 456 KB Output is correct
5 Correct 3 ms 712 KB Output is correct
6 Correct 4 ms 712 KB Output is correct
7 Correct 3 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 3 ms 716 KB Output is correct
3 Correct 6 ms 712 KB Output is correct
4 Correct 7 ms 712 KB Output is correct
5 Correct 4 ms 716 KB Output is correct
6 Correct 5 ms 460 KB Output is correct
7 Correct 6 ms 712 KB Output is correct