Submission #172486

# Submission time Handle Problem Language Result Execution time Memory
172486 2020-01-01T17:56:45 Z emil_physmath Xoractive (IZhO19_xoractive) C++17
0 / 100
4 ms 592 KB
#include <algorithm>
#include "interactive.h"
#include <vector>
#include <map>
#include <iostream>
using namespace std;
typedef long long llong;

int ans[101];
map<int, bool> isInQ;

inline vector<int> Range(int l, int r)
{
    vector<int> a;
    for (int i = l; i <= r; ++i)
        a.push_back(i);
    return a;
}
inline vector<int> LeftHalf(pair<int, int> range)
{
    return Range(range.first, (range.first + range.second) / 2);
}
vector<int> Get(vector<int> ind)
{
    isInQ.clear();
    auto it = find(ind.begin(), ind.end(), 1);
    if (it != ind.end())
        ind.erase(it);
    vector<int> a = get_pairwise_xor(ind);
    ind.push_back(1);
    vector<int> b = get_pairwise_xor(ind);
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    vector<int> res;
    for (int i = (int)b.size() - 1; i >= 0; --i)
        if (!a.empty() && b[i] == a.back())
            a.pop_back();
        else
            isInQ[b[i] ^ ans[1]] = true;
}
vector<int> guess(int n)
{
    ans[0] = ask(1);
    vector<int> a = Get(Range(2, n));
    for (int i = 0; i < a.size(); ++i)
        ans[i + 2] = a[i];
    vector<pair<int, int>> lr;
    lr.push_back({2, n});
    while (lr.size())
    {
        vector<int> q;
        for (int i = 0; i < lr.size(); ++i)
        {
            auto temp = LeftHalf(lr[i]);
            q.insert(q.end(), temp.begin(), temp.end());
        }
        Get(q);
        vector<pair<int, int>> newLr;
        for (int i = 0; i < lr.size(); ++i)
        {
            sort(ans + lr[i].first, ans + lr[i].second + 1, [](int a, int b) {
                 return isInQ[a] > isInQ[b];
            });
            if (lr[i].first != lr[i].second)
            {
                int m = (lr[i].first + lr[i].second) / 2;
                newLr.push_back({lr[i].first, m});
                newLr.push_back({m + 1, lr[i].second});
            }
        }
        lr.swap(newLr);
    }
    return vector<int>(ans + 1, ans + n + 1);
}

Compilation message

Xoractive.cpp: In function 'std::vector<int> Get(std::vector<int>)':
Xoractive.cpp:40:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:45:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < a.size(); ++i)
                     ~~^~~~~~~~~~
Xoractive.cpp:52:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < lr.size(); ++i)
                         ~~^~~~~~~~~~~
Xoractive.cpp:59:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < lr.size(); ++i)
                         ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 592 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -