Submission #181890

# Submission time Handle Problem Language Result Execution time Memory
181890 2020-01-09T10:49:34 Z stefdasca Xoractive (IZhO19_xoractive) C++14
0 / 100
2 ms 376 KB
#include "interactive.h"
using namespace std;

int xorr[12], sol[102];
vector<int> query[12];
int process(vector<int> v)
{
    int occ = 1;
    int cv = v[0];
    int ans = 0;
    for(int i = 1; i < v.size(); ++i)
    {
        if(v[i] == v[i-1])
            ++occ;
        else
        {
            occ /= 2;
            if(occ & 1)
                ans ^= cv;
            occ = 1;
            cv = v[i];
        }
    }
    occ /= 2;
    if(occ & 1)
        ans ^= cv;
    return ans;
}
vector<int> guess(int n)
{
    int nr = 1;
    for(int i = n; i >= 1; --i)
        query[nr].push_back(i);
    vector<int> xors = get_pairwise_xor(query[1]);
    xorr[nr] = process(xors);
    for(int bit = 0; (1<<bit) <= n; ++bit)
    {
        ++nr;
        for(int i = n; i >= 1; --i)
            if(i & (1<<bit))
                query[nr].push_back(i);
        xorr[nr] = process(get_pairwise_xor(query[nr]));
    }
    for(int i = 1; i <= n; ++i)
    {
        int orr = 0;
        for(int j = 2; j <= nr; ++j)
            if(!i & (1<<(j-1)))
                orr |= xorr[j];
        sol[i] = xorr[1] ^ orr;
        xorr[1] ^= sol[i];
        for(int j = 2; j <= nr; ++j)
            if(i & (1<<(j-1)))
                xorr[j] ^= sol[i];
    }
    vector<int>ans;
    for(int i = 1; i <= n; ++i)
        ans.push_back(sol[i]);
    return ans;
}

Compilation message

Xoractive.cpp: In function 'int process(std::vector<int>)':
Xoractive.cpp:11:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 1; i < v.size(); ++i)
                    ~~^~~~~~~~~~
Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:48:16: warning: suggest parentheses around operand of '!' or change '&' to '&&' or '!' to '~' [-Wparentheses]
             if(!i & (1<<(j-1)))
                ^~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output is not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 376 KB Output is not correct
2 Halted 0 ms 0 KB -