답안 #171067

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
171067 2019-12-27T09:53:13 Z SamAnd Xoractive (IZhO19_xoractive) C++17
0 / 100
11 ms 376 KB
#include "interactive.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 102;

int ans[N];

vector<int> gget_pairwise_xor(vector<int> v)
{
    if (v.empty())
        return v;
    vector<int> res = get_pairwise_xor(v);
    reverse(res.begin(), res.end());
    for (int i = 0; i < v.size(); ++i)
        res.pop_back();
    reverse(res.begin(), res.end());
    vector<int> yres;
    for (int i = 0; i < res.size(); i += 2)
        yres.push_back(res[i]);
    return yres;
}

vector<int> han(vector<int> a, vector<int> b)
{
    vector<int> res;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    int j = 0;
    for (int i = 0; i < a.size(); ++i)
    {
        if (j < b.size() && a[i] == b[j])
        {
            ++j;
            continue;
        }
        res.push_back(a[i]);
    }
    return res;
}
vector<int> hat(vector<int> a, vector<int> b)
{
    vector<int> res;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    int i = 0, j = 0;
    while (1)
    {
        if (i == a.size() || j == b.size())
            return res;
        if (a[i] == b[j])
        {
            res.push_back(a[i]);
            ++i;
            ++j;
            continue;
        }
        if (a[i] < b[j])
            ++i;
        else
            ++j;
    }
}

vector<int> v[8];

vector<int> t;
vector<int> v1, v2;
vector<int> guess(int n)
{
    ans[1] = ask(1);
    for (int i = 0; i < 7; ++i)
    {
        t.clear();
        t.push_back(1);
        for (int x = 2; x <= n; ++x)
        {
            if ((x & (1 << i)))
                t.push_back(x);
        }
        v1 = gget_pairwise_xor(t);
        t.clear();
        for (int x = 2; x <= n; ++x)
        {
            if ((x & (1 << i)))
                t.push_back(x);
        }
        v2 = gget_pairwise_xor(t);
        v[i] = han(v1, v2);
        for (int j = 0; j < v[i].size(); ++j)
            v[i][j] ^= ans[1];
        for (int j = 0; j < v[i].size(); ++j)
            v[7].push_back(v[i][j]);
    }
    v[7].push_back(ask(n));
    for (int x = 2; x <= n; ++x)
    {
        t.clear();
        t = v[7];
        for (int i = 0; i < 7; ++i)
        {
            if ((x & (1 << i)))
                t = hat(t, v[i]);
            else
                t = hat(t, han(v[7], v[i]));
        }
        ans[x] = t[0];
    }
    ///////////////////////////9//////////////////////
    vector<int> vans;
    for (int i = 1; i <= n; ++i)
        vans.push_back(ans[i]);
	return vans;
}

Compilation message

Xoractive.cpp: In function 'std::vector<int> gget_pairwise_xor(std::vector<int>)':
Xoractive.cpp:14:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < v.size(); ++i)
                     ~~^~~~~~~~~~
Xoractive.cpp:18:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < res.size(); i += 2)
                     ~~^~~~~~~~~~~~
Xoractive.cpp: In function 'std::vector<int> han(std::vector<int>, std::vector<int>)':
Xoractive.cpp:29:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < a.size(); ++i)
                     ~~^~~~~~~~~~
Xoractive.cpp:31:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (j < b.size() && a[i] == b[j])
             ~~^~~~~~~~~~
Xoractive.cpp: In function 'std::vector<int> hat(std::vector<int>, std::vector<int>)':
Xoractive.cpp:48:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (i == a.size() || j == b.size())
             ~~^~~~~~~~~~~
Xoractive.cpp:48:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (i == a.size() || j == b.size())
                              ~~^~~~~~~~~~~
Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:89:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j < v[i].size(); ++j)
                         ~~^~~~~~~~~~~~~
Xoractive.cpp:91:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j < v[i].size(); ++j)
                         ~~^~~~~~~~~~~~~
Xoractive.cpp:110:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for (int i = 1; i <= n; ++i)
     ^~~
Xoractive.cpp:112:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  return vans;
  ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output is not correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 376 KB Output is not correct
2 Halted 0 ms 0 KB -