Submission #519222

# Submission time Handle Problem Language Result Execution time Memory
519222 2022-01-26T03:58:27 Z Ai7081 Xoractive (IZhO19_xoractive) C++17
0 / 100
1 ms 456 KB
#include <bits/stdc++.h>
using namespace std;

int ask(int i);

vector<int> get_pairwise_xor(vector<int> pos);

vector<int> guess(int n) {
    vector<int> ret(n+1);
    ret[1] = ask(1);
    vector<int> q;
    vector<vector<int>> bit(7);
    for (int i=0; i<7; i++) {
        q.clear();
        for (int j=1; j<=n; j++) {
            if ((j>>i)%2 && j>1) q.push_back(j);
        }
        vector<int> res1, res2;
        res1 = get_pairwise_xor(q);
        q.push_back(1);
        res2 = get_pairwise_xor(q);
        vector<bool> mark(n+5, false);
        int ii=0, jj=0;
        while (ii<res1.size() && jj<res2.size()) {
            if (res1[ii] < res2[jj]) ii++;
            else if (res1[ii] > res2[jj]) jj++;
            else {
                mark[jj] = true;
                ii++;
                jj++;
            }
        }
        for (int j=0; j<res2.size(); j++) {
            if (!mark[j]) bit[i].push_back(res2[j]);
        }
        for (int j=0; j<bit[i].size(); j++) bit[i][j] = (bit[i][j] ^ ret[1]);
    }
    vector<pair<int, int>> v;
    for (int i=0; i<7; i++) {
        for (auto x : bit[i]) {
            bool ok = false;
            for (int j=0; j<v.size(); j++) {
                if (x == v[j].first) {
                    v[j].second += (1<<i);
                    ok = true;
                    break;
                }
            }
            if (!ok) {
                v.push_back({x, (1<<i)});
            }
        }
    }
    for (auto [x, idx] : v) ret[idx] = x;
    return ret;
}

Compilation message

Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:24:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         while (ii<res1.size() && jj<res2.size()) {
      |                ~~^~~~~~~~~~~~
Xoractive.cpp:24:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         while (ii<res1.size() && jj<res2.size()) {
      |                                  ~~^~~~~~~~~~~~
Xoractive.cpp:33:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for (int j=0; j<res2.size(); j++) {
      |                       ~^~~~~~~~~~~~
Xoractive.cpp:36:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for (int j=0; j<bit[i].size(); j++) bit[i][j] = (bit[i][j] ^ ret[1]);
      |                       ~^~~~~~~~~~~~~~
Xoractive.cpp:42:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |             for (int j=0; j<v.size(); j++) {
      |                           ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 200 KB Not correct size
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 456 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -