# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
707371 | beaconmc | Xoractive (IZhO19_xoractive) | C++14 | 7 ms | 464 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "interactive.h"
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef int ll;
using namespace std;
//using namespace __gnu_pbds;
#define FOR(i, x, y) for(ll i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)
//#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
int one = -1;
vector<int> getxor(vector<int> lis){
vector<int> ans = get_pairwise_xor(lis);
vector<int> realans;
FOR(i,0,ans.size()){
if (i%2==0) continue;
if (ans[i] == 0) continue;
realans.push_back(ans[i]);
}
return realans;
}
vector<int> getnum(vector<int> lis){
vector<int> sus = getxor(lis);
lis.push_back(1);
vector<int> sus2 = getxor(lis);
while (sus.size() != 0){
FOR(i,0,sus2.size()) if (sus2[i] == sus[sus.size()-1]){sus.pop_back(); sus2[i] = -1;break;}
}
vector<int> temp;
for (auto i : sus2){
if (i != -1) temp.push_back(i^one);
}
return temp;
}
int intersect(vector<vector<int>> idk){
for (auto&i : idk[0]){
bool flag = false;
for (auto&j : idk){
if (!count(j.begin(),j.end(),i)) flag = true;
}
if (!flag) return i;
}
}
vector<int> imp[8];
vector<int> guess(int n) {
set<ll> everything;
one = ask(1);
FOR(i,2,n+1){
FOR(j,0,7){
if (i & (1<<j)) imp[j].push_back(i);
}
}
FOR(i,0,7){
if (imp[i].size()) imp[i] = getnum(imp[i]);
}
for (auto&i : imp){
for (auto&j : i){
everything.insert(j);
}
}
imp[0].push_back(one);
vector<int> ans;
FOR(i,1,n+1){
vector<vector<int>> temp;
FOR(j,0,7){
if (i & (1<<j)) temp.push_back(imp[j]);
else{
vector<int> temp2;
set<ll> idk;
for (auto&k : imp[j]) idk.insert(k);
for (auto&k : everything) if (idk.count(k) == 0) temp2.push_back(k);
temp.push_back(temp2);
}
}
ans.push_back(intersect(temp));
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |