답안 #182077

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
182077 2020-01-09T11:39:33 Z stefdasca Xoractive (IZhO19_xoractive) C++14
컴파일 오류
0 ms 0 KB
#include "interactive.h"
#include<bits/stdc++.h>
using namespace std;

int n, sol[102];
vector<int> guess(int n)
{
    sol[1] = ask(1);
    map<int, int> ind;
    for(int i = 0; i <= 6; ++i)
    {
        vector<int> vec;
        for(int j = 2; j <= n; ++j)
            if(j & (1<<i))
                vec.push_back(j);
        if(vec.empty())
            continue;
        vector<int> vv = vec;
        vv.push_back(1);
        vv = get_pairwise_xor(vv);
        vec = get_pairwise_xor(vec);
        map<int, int> frq;
        for(int j = 0; j < vv.size(); ++j)
            if(vv[j] != 0)
                frq[vv[j]]++;
        for(int j = 0; j < vec.size(); ++j)
            if(vv[j] != 0)
                frq[vv[j]]--;
        for(int j = 0; j < vv.size(); ++j)
            if(frq[vv[j]] != 0)
                ind[(vv[j] ^ sol[1])] |= (1<<i);
    }
    for(auto poz : ind)
        sol[poz.second] = poz.first;
    for(int i = 1; i <= n; ++i)
        ans.push_back(sol[i]);
    return ans;
}

Compilation message

Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:23:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 0; j < vv.size(); ++j)
                        ~~^~~~~~~~~~~
Xoractive.cpp:26:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 0; j < vec.size(); ++j)
                        ~~^~~~~~~~~~~~
Xoractive.cpp:29:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 0; j < vv.size(); ++j)
                        ~~^~~~~~~~~~~
Xoractive.cpp:36:9: error: 'ans' was not declared in this scope
         ans.push_back(sol[i]);
         ^~~
Xoractive.cpp:36:9: note: suggested alternative: 'abs'
         ans.push_back(sol[i]);
         ^~~
         abs
Xoractive.cpp:37:12: error: 'ans' was not declared in this scope
     return ans;
            ^~~
Xoractive.cpp:37:12: note: suggested alternative: 'abs'
     return ans;
            ^~~
            abs