Submission #203007

# Submission time Handle Problem Language Result Execution time Memory
203007 2020-02-19T02:25:06 Z guangxuan Xoractive (IZhO19_xoractive) C++14
0 / 100
6 ms 376 KB
#include "interactive.h"
#include <unordered_map>
#include <vector>
using namespace std;



unordered_map<int,int> m2vec(vector<int> v,int n){
    unordered_map<int,int> res;
    for(int i=n;i<v.size();i+=2)res[v[i]]++;
    return res;
}

vector<int> getnums(vector<int> pos,int an,int n){
    vector<int> qp;
    for(int i:pos)qp.push_back(i);
    unordered_map<int,int> qr1 = m2vec(get_pairwise_xor(qp),(int)qp.size());
    qp.push_back(n);
    unordered_map<int,int> qr2 = m2vec(get_pairwise_xor(qp),(int)qp.size());
    for(pair<int,int> i:qr1){
        qr2[i.first]-=i.second;
        if(qr2[i.first]==0)qr2.erase(i.first);
    }
    vector<int> nums;
    for(pair<int,int> i:qr2){
        nums.push_back(i.first ^ an);
    }
    return nums;
}

vector<int> guess(int n) {
    int an = ask(n);
    int l2;
    if(n==2)l2=1;
    else l2=3;
    unordered_map<int,int> valuetoindex;
    for(int bi=0;bi<l2;bi++){
        vector<int> pos;
        for(int j=1;j<n;j++){
            if(j&(1<<bi)){
                pos.push_back(j);
            }
        }
        vector<int> res = getnums(pos,an,n);
        for(int i:res){
            valuetoindex[i]+=1<<bi;
        }
    }
    vector<int> ans(n);
    ans[n-1] = an;
    for(pair<int,int> i:valuetoindex){
        ans[i.second-1] = i.first;
    }
    return ans;
}

Compilation message

Xoractive.cpp: In function 'std::unordered_map<int, int> m2vec(std::vector<int>, int)':
Xoractive.cpp:10:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=n;i<v.size();i+=2)res[v[i]]++;
                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 248 KB Not correct size
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 376 KB Output is not correct
2 Halted 0 ms 0 KB -