Submission #1349810

#TimeUsernameProblemLanguageResultExecution timeMemory
1349810adscodingXoractive (IZhO19_xoractive)C++20
Compilation error
0 ms0 KiB
#include "interactive.h"
#include <bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define fi first
#define se second
#define FOR(i, a, b) for (int i = a, _b = b; i <= _b; ++i)
#define FORD(i, a, b) for (int i = a, _b = b; i >= _b; --i)
#define FORLL(i, a, b) for (ll i = a, _b = b; i <= _b; ++i)
#define FORDLL(i, a, b) for (ll i = a, _b = b; i >= _b; --i)
#define all(x) x.begin(), x.end()
#define uni(x) sort(all(x)), x.erase(unique(all(x)), x.end())
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define dbg(...) debug(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void __prine_one(const char *&s, const T &x)
{
    while (*s == ' ') ++s;
    const char *p = s;
    int bal = 0;
    while (*s)
    {
        if (*s == '(') ++bal;
        else if (*s == ')') --bal;
        else if (*s == ',' && bal == 0) break;
        ++s;
    }
    cerr.write(p, s - p) << " = " << x;
    if (*s == ',')
    {
        cerr << "  ,  ";
        ++s;
    }
}

template<typename... Args>
void debug(const char *s, Args... args)
{
    cerr << "[  ";
    int dummy[] = {0, (__prine_one(s, args), 0)...};
    (void)dummy;
    cerr << "  ]\n\n";
}

template<class X>
bool maximize(X &a, const X &b)
{
    if (b > a)
    {
        a = b;
        return true;
    }
    return false;
}

template<class X>
bool minimize(X &a, const X &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

// --------------------------------------------------------------------------------------------



// --------------------------------------------------------------------------------------------

// FUNCTIONS OF INTERACTIVE
#ifndef ONLINE_JUDGE

int ask(int i)
{
    cout << "ask " << i << endl;
    int res; cin >> res;
    return res;
}

vector<int> get_pairwise_xor(vector<int> &vec)
{
    cout << "get_pairwise_xor ";
    for (int x : vec)
        cout << x << ' ';
    cout << endl;
    vector<int> vecres;
    FOR(i, 1, SZ(vec) * SZ(vec))
    {
        int x; cin >> x;
        vecres.push_back(x);
    }
    return vecres;
}

#endif

multiset<int> toSet(vector<int> vec)
{
    multiset<int> ms;
    for (int x : vec)
        ms.insert(x);
    return ms;
}

vector<int> guess(int n)
{
    // cong 1 vao khi goi ask hoac get_pairwise_xor
    vector<int> a(n, 0);
    vector<vector<int>> vecAsk(7);
    map<int, int> mp;
    FOR(mask, 1, n - 1)
    {
        FOR(i, 0, 6)
        {
            if (mask >> i & 1)
                vecAsk[i].push_back(mask + 1);
        }
    }

    a[0] = ask(1);

    FOR(bit, 0, 6)
    {
        if (vecAsk[bit].empty()) continue;
        multiset<int> B = toSet(get_pairwise_xor(vecAsk[bit]));
        vecAsk[bit].push_back(1);
        multiset<int> A = toSet(get_pairwise_xor(vecAsk[bit]));
        for (int x : B)
            A.erase(A.find(x));
        A.erase(A.find(0));

        for (int x : A)
        {
            mp[x ^ a[0]] |= 1 << bit;
        }
    }

    for (const auto &p : mp)
    {
        a[p.se] = p.fi;
    }

    return a;
}

// MAIN
#ifndef ONLINE_JUDGE
signed main()
{
    // ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    // #define TASK "TEST"
    // if (fopen(TASK".INP", "r"))
    // {
    //     freopen(TASK".INP", "r", stdin);
    //     freopen(TASK".OUT", "w", stdout);
    // }
    //
    int n; cin >> n;
    vector<int> vec = guess(n);
    cout << "! ";
    for (int x : vec) cout << x << ' ';
    cout << endl;
    return 0;
}
#endif

Compilation message (stderr)

Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:133:49: error: call of overloaded 'get_pairwise_xor(__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type&)' is ambiguous
  133 |         multiset<int> B = toSet(get_pairwise_xor(vecAsk[bit]));
      |                                 ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
In file included from Xoractive.cpp:1:
interactive.h:8:18: note: candidate: 'std::vector<int> get_pairwise_xor(std::vector<int>)'
    8 | std::vector<int> get_pairwise_xor(std::vector<int> positions);
      |                  ^~~~~~~~~~~~~~~~
Xoractive.cpp:88:13: note: candidate: 'std::vector<int> get_pairwise_xor(std::vector<int>&)'
   88 | vector<int> get_pairwise_xor(vector<int> &vec)
      |             ^~~~~~~~~~~~~~~~
Xoractive.cpp:135:49: error: call of overloaded 'get_pairwise_xor(__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type&)' is ambiguous
  135 |         multiset<int> A = toSet(get_pairwise_xor(vecAsk[bit]));
      |                                 ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
interactive.h:8:18: note: candidate: 'std::vector<int> get_pairwise_xor(std::vector<int>)'
    8 | std::vector<int> get_pairwise_xor(std::vector<int> positions);
      |                  ^~~~~~~~~~~~~~~~
Xoractive.cpp:88:13: note: candidate: 'std::vector<int> get_pairwise_xor(std::vector<int>&)'
   88 | vector<int> get_pairwise_xor(vector<int> &vec)
      |             ^~~~~~~~~~~~~~~~