Submission #713851

# Submission time Handle Problem Language Result Execution time Memory
713851 2023-03-23T06:10:41 Z Pacybwoah Xoractive (IZhO19_xoractive) C++14
0 / 100
13 ms 900 KB
#include "interactive.h"
#include<vector>
#include<map>
#include<algorithm>
using namespace std;

vector<int> guess(int n) {
	vector <int> ans(n);
    int one=ask(1);
	vector<vector<int>> bitxor(7),askans(7),noone(7);
    for(int i=0;i<7;i++) bitxor[i].push_back(1);
    for(int i=2;i<=n;i++){
        for(int j=0;j<7;j++){
            if(i&(i<<j)) bitxor[j].push_back(i);
        }
    }
    for(int i=0;i<7;i++){
        if(!bitxor[i].empty()) askans[i]=get_pairwise_xor(bitxor[i]);
        bitxor[i].erase(bitxor[i].begin());
        if(!bitxor[i].empty()) noone[i]=get_pairwise_xor(bitxor[i]);
        else continue;
        for(int j=0;j<noone[i].size();j++){
            askans[i].erase(find(askans[i].begin(),askans[i].end(),noone[i][j]));
        }
        while(*askans[i].begin()==0) askans[i].erase(askans[i].begin());
    }
    map<int,int> m;
    for(int i=0;i<7;i++){
        for(int j=0;j<askans[i].size();j++){
            askans[i][j]^=one;
            m[askans[i][j]]+=(1<<i);
        }
    }
    ans[0]=one;
    for(auto x:m){
        ans[x.second-1]=x.first;
    }
	return ans;
}

Compilation message

Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:22:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for(int j=0;j<noone[i].size();j++){
      |                     ~^~~~~~~~~~~~~~~~
Xoractive.cpp:29:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for(int j=0;j<askans[i].size();j++){
      |                     ~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Output is not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 13 ms 900 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -