# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1125580 | Lemser | Xoractive (IZhO19_xoractive) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "interactive.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
using lld = long double;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vlld = vector<lld>;
// #define endl '\n'
#define all(x) x.begin(),x.end()
#define lsb(x) x&(-x)
#define gcd(a,b) __gcd(a,b)
#define sz(x) (int)x.size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fls cout.flush()
#define fore(i,l,r) for(auto i=l;i<r;i++)
#define fo(i,n) fore(i,0,n)
#define forex(i,r,l) for(auto i=r; i>=l;i--)
#define ffo(i,n) forex(i,n-1,0)
bool cmin(ll &a, ll b) { if(b<a){a=b;return 1;}return 0; }
bool cmax(ll &a, ll b) { if(b>a){a=b;return 1;}return 0; }
void valid(ll in) { cout<<((in)?"YES\n":"NO\n"); }
ll lcm(ll a, ll b) { return (a/gcd(a,b))*b; }
ll gauss(ll n) { return (n*(n+1))/2; }
vector <int> ans;
map<ll, ll> tops;
vector<int> find (vector<int> &ids) {
vector<int> R = ids;
auto B = get_pairwise_xor(R);
R.pb(1);
auto A = get_pairwise_xor(R);
multiset<ll> st;
for (ll v: A) st.insert(v);
for (ll v: B) st.erase(st.find(v));
while (*st.begin() == 0) st.erase(st.find(0));
vector<int> x;
for (ll v: st) {
ll r = (v^ans[0]);
if (sz(x) && x.back() == r) continue;
x.pb(r);
}
return x;
}
vector<int> guess(int n) {
ans = vector<int>(n);
ans[0] = ask(1);
fo (b, 20) {
if ((1<<b) > n-1) break;
vll ids;
fo (i, n) {
if ((i&(1<<b)) == 0) continue;
ids.pb(i);
}
vll A = find(ids);
for (ll v: A) tops[v] += 1<<b;
}
for (auto [k, v]: tops) ans[v] = k;
return ans;
}
// void test_case () {
// }
// int main() {
// cin.tie(0)->sync_with_stdio(0);
// int tt = 1;
// // cin >> tt;
// while (tt--) test_case();
// }