답안 #256398

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
256398 2020-08-02T16:11:48 Z karma Xoractive (IZhO19_xoractive) C++14
6 / 100
4 ms 384 KB
#include <bits/stdc++.h>
#include "interactive.h"
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair
//#define int         int64_t

using namespace std;
const int N = 107;

int ans[N];
//
//vector<int> get_pairwise_xor(vector<int> pos) {
//    vector<int> res;
//    cout << "ask: ";
//    for(int x: pos) cout << x << ' ';
//    cout << "\n"; cout << "answer: ";
//    for(int x: pos) {
//        for(int y: pos) {
//            res.pb(ans[x] ^ ans[y]);
//            cout << (ans[x] ^ ans[y]) << ' ';
//        }
//    }
//    cout << '\n';
//    return res;
//}
//
//int ask(int i) {return ans[i];}

vector<int> get_xor(vector<int>& pos) {
    auto tmp = get_pairwise_xor(pos);
    sort(tmp.begin(), tmp.end());
    vector<int> ans;
    for(int i = 0; i < tmp.size(); i += 2) {
        if(tmp[i] == 0) continue;
        ans.pb(tmp[i]);
    }
    return ans;
}

set<int> get_ans(int cur, vector<int>& pos) {
    auto tmp1 = get_xor(pos);
    pos.pb(1);
    auto tmp2 = get_xor(pos);
    set<int> res;
    map<int, int> cnt;
    for(auto x: tmp2) ++cnt[x];
    for(auto x: tmp1) --cnt[x];
    for(auto x: cnt)
        if(x.se)
            res.insert(x.fi ^ cur);
    return res;
}

set<int> value[10];

vector<int> guess(int n) {
    vector<int> res(n), pos;
    if(n <= 15) {
        for(int i = 0; i < n; ++i) res[i] = ask(i + 1);
        return res;
    }
    res[0] = ask(1);
    for(int i = 0; i < 7; ++i) {
        pos.clear();
        for(int j = 1; j < n; ++j)
            if(j >> i & 1) pos.pb(j + 1);
        value[i] = get_ans(res[0], pos);
        cout << i << '\n';
        for(int x: value[i]) cout << x << ' ';
        cout << '\n';
    }
    set<int> can;
    for(int j = n - 1; j > 0; --j) {
        bool start = 0; can.clear();
        for(int i = 0; i < 7; ++i) {
            if(j >> i & 1) {
                if(!start) can = value[i], start = 1;
                else {
                    //for(int x: can) cout << x << ' ';
                    //cout << '\n';
                    vector<int> del;
                    for(int x: can)
                        if(!value[i].count(x)) del.pb(x);
                    for(int x: del) can.erase(x);
                }
            }
        }
        res[j] = *can.begin();
        for(int i = 0; i < 7; ++i)
            if(j >> i & 1) value[i].erase(res[j]);
    }
    return res;
}

//int32_t main() {
//    ios_base::sync_with_stdio(0);
//    cin.tie(0), cout.tie(0);
//    #define Task        "test"
//    if(fopen(Task".inp", "r")) {
//        freopen(Task".inp", "r", stdin);
//        freopen(Task".out", "w", stdout);
//    }
//    int n; cin >> n;
//    for(int i = 1; i <= n; ++i) cin >> ans[i];
//    auto res = guess(n);
//    for(int x: res) cout << x << ' ';
//}

Compilation message

Xoractive.cpp: In function 'std::vector<int> get_xor(std::vector<int>&)':
Xoractive.cpp:36:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < tmp.size(); i += 2) {
                    ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Failed 4 ms 384 KB do not print anything to standard output
2 Halted 0 ms 0 KB -