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 "chameleon.h"
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define pll pair<int, pii>
#define pii pair<int, int>
#define fi first
#define se second
using namespace std;
const int N = 1e5+2;
const int M = 60;
const int mod = 1e9+7;
const ll base = 1e6;
const ll inf = 1e9;
int n, m, b[N], a[N], k, t, d[N], cnt, par[N], f[N];
ll ans;
vector<int> adj[N];
bool vis[N], ok;
bool ask(vector<int> vi, int x)
{
if(vi.empty())return false;
vi.pb(x);
return Query(vi) != (int) vi.size();
}
void Solve(int n)
{
n *= 2;
for(int i = 1; i <= n; i ++)
{
vector<int> group[2];
fill_n(a, i, -1);
queue<int> q;
for(int j = 1; j < i; j ++)
{
if(a[j] == -1)
{
a[j] = 0;
q.push(j);
while(!q.empty())
{
int u = q.front();
q.pop();
for(int v: adj[u])
{
if(a[v] == -1)
{
a[v] = a[u]^1;
q.push(v);
}
}
}
}
group[a[j]].pb(j);
}
for(int j = 0; j < 2; j ++)
{
while(ask(group[j], i))
{
int l = 1, r = group[j].size(), mid;
while(l <= r)
{
mid = (l+r)>>1;
if(ask(vector<int>(group[j].begin(), group[j].begin()+mid), i))r = mid-1;
else l = mid+1;
}
adj[group[j][l-1]].pb(i);
adj[i].pb(group[j][l-1]);
group[j].erase(group[j].begin(), group[j].begin()+l);
}
}
}
for(int i = 1; i <= n; i ++)
{
if(adj[i].size() == 1)continue;
while(Query({i, adj[i][0], adj[i][1]}) != 1)
rotate(adj[i].begin(), adj[i].begin()+1, adj[i].end());
b[adj[i][2]] ^= i;
b[i] ^= adj[i][2];
}
for(int i = 1; i <= n; i ++)
{
if(adj[i].size() == 1)b[i] = adj[i][0];
else for(int j = 0; j < 3; j ++)b[i] ^= adj[i][j];
if(b[i] > i)Answer(i, b[i]);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |