# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
154987 | Pankin | Xoractive (IZhO19_xoractive) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "interactive.h"
#define mp make_pair
#define ll long long
#define ld long double
#define pb push_back
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fs first
#define sc second
#define getfiles ifstream cin("input.txt"); ofstream cout("output.txt");
#define endl '\n'
#define con continue
#define pii pair<ll, ll>
#define all(x) x.begin(), x.end()
using namespace std;
vector<int> a;
set<int> getMn(set<int> ind) {
vector<int> pos;
for (auto i = ind.begin(); i != ind.end(); i++)
pos.pb(*i);
pos.pb(1);
vector<int> px1 = get_pairwise_xor(pos);
pos.pop_back();
vector<int> px2 = get_pairwise_xor(pos);
set<int> ans;
multiset<int> temp;
for (int i = 0; i < px1.size(); i++)
temp.insert(px1[i]);
for (int i = 0; i < px2.size(); i++)
temp.erase(temp.find(px2[i]));
for (auto i = temp.begin(); i != temp.end(); i++)
ans.insert(*i ^ a[1]);
ans.erase(a[1]);
return ans;
}
vector<int> guess(int n) {
a.resize(n + 1);
set<int> all;
a[1] = ask(1);
vector< vector< set<int> > > mn(7, vector< set<int> >(2)), ind(7, vector< set<int> >(2));
for (int i = 2; i <= n; i++) {
for (int j = 6; j >= 0; j--) {
ind[j][(i>>j)%2].pb(i);
}
}
for (int j = 6; j >= 0; j--) {
mn[j][1] = getMn(ind[j][1]);
for (auto i = mn[j][1].begin(); i != mn[j][1].end(); i++)
all.insert(*i);
}
for (int j = 6; j >= 0; j--) {
mn[j][0] = all;
for (auto i = mn[j][1].begin(); i != mn[j][1].end(); i++)
mn[j][0].erase(*i);
}
for (int i = 2; i <= n; i++) {
set<int> cur = all;
for (int j = 6; j >= 0; j--) {
for (auto it = all.begin(); it != all.end(); it++) {
if (mn[j][(i>>j)%2].find(*it) == mn[j][(i>>j)%2].end())
cur.erase(*it);
}
}
a[i] = *cur.begin();
}
a.erase(a.begin());
return a;
}