Submission #424851

#TimeUsernameProblemLanguageResultExecution timeMemory
424851dooweyXoractive (IZhO19_xoractive)C++14
0 / 100
12 ms540 KiB
#include "interactive.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair

const int B = 7;
vector<int> has[B];
vector<int> nob[B];

vector<int> intersect(vector<int> A, vector<int> B){
    int jj = 0;
    vector<int> res;
    for(auto x : A){
        while(jj < B.size() && B[jj] < x){
            jj ++ ;
        }
        if(jj < B.size() && B[jj] == x){
            res.push_back(x);
        }
    }
    return res;
}

vector<int> guess(int n) {
	int base = ask(1);
    for(int lg = 0 ; lg < B; lg ++ ){
        vector<int> res;
        res.push_back(1);
        for(int i = 2; i <= n; i ++ ){
            if((i & (1 << lg)))
                res.push_back(i);
        }
        vector<int> chk, ff;
        chk = get_pairwise_xor(res);
        for(auto x : chk){
            if(x != 0)
                ff.push_back(x);
        }
        has[lg] = ff;
        vector<int> nah;
        nah.push_back(1);
        for(int i = 2; i <= n; i ++ ){
            if((i & (1 << lg))){
                continue;
            }
            nah.push_back(i);
        }

        chk = get_pairwise_xor(nah);
        ff.clear();
        for(auto x : chk){
            if(x != 0)
                ff.push_back(x);
        }
        nob[lg] = ff;
    }
    vector<int> outp = {base};
    vector<int> rr;
    vector<int> cur;
    for(int id = 2; id <= n; id ++ ){
        rr.clear();
        for(int lg = 0; lg < B; lg ++ ){
            if((id & (1 << lg))){
                cur = has[lg];
            }
            else{
                cur = nob[lg];
            }
            if(rr.empty()) rr = cur;
            else rr = intersect(rr, cur);
        }
        outp.push_back((rr[0] ^ base));
    }
	return outp;
}

Compilation message (stderr)

Xoractive.cpp: In function 'std::vector<int> intersect(std::vector<int>, std::vector<int>)':
Xoractive.cpp:21:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         while(jj < B.size() && B[jj] < x){
      |               ~~~^~~~~~~~~~
Xoractive.cpp:24:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         if(jj < B.size() && B[jj] == x){
      |            ~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...