답안 #181887

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
181887 2020-01-09T10:49:05 Z stefdasca Xoractive (IZhO19_xoractive) C++14
컴파일 오류
0 ms 0 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.pb(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)))
                ^~
Xoractive.cpp:58:13: error: 'class std::vector<int>' has no member named 'pb'
         ans.pb(sol[i]);
             ^~