# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
404957 | Victor | Chameleon's Love (JOI20_chameleon) | C++17 | 0 ms | 0 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 "chameleon.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define per(i, a, b) for (int i = b - 1; i >= (a); --i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back
#define umap unordered_map
#define uset unordered_set
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;
const int INF = 1'000'000'007;
namespace {
int variable_example = 1;
} // namespace
bitset<1001> taken;
void bsearch(vi chams, int cham) {
if (sz(chams) == 1) {
taken[chams[0]-1] = 1;
Answer(cham, chams[0]);
return;
}
int si = sz(chams);
vi next(si >> 1);
rep(i, 0, si >> 1) next[i] = chams[i];
int c1 = Query(next);
next.pb(cham);
int c2 = Query(next);
if (c1 == c2)
next.pop_back();
else {
next.clear();
rep(i, si >> 1, si)next.pb(chams[i]);
}
bsearch(next,cham);
}
void Solve(int n) {
rep(i, 0, n*2) {
if (taken[i]) continue;
taken[i] = 1;
vi vec;
rep(j, 0, n*2) if (!taken[j]) vec.pb(j + 1);
bsearch(vec,i+1);
}
}#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define per(i, a, b) for (int i = b - 1; i >= (a); --i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back
#define umap unordered_map
#define uset unordered_set
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;
const int INF = 1'000'000'007;
namespace {
int variable_example = 1;
} // namespace
bitset<1001> taken;
void bsearch(vi chams, int cham) {
if (sz(chams) == 1) {
taken[chams[0]-1] = 1;
Answer(cham, chams[0]);
return;
}
int si = sz(chams);
vi next(si >> 1);
rep(i, 0, si >> 1) next[i] = chams[i];
int c1 = Query(next);
next.pb(cham);
int c2 = Query(next);
if (c1 == c2)
next.pop_back();
else {
next.clear();
rep(i, si >> 1, si)next.pb(chams[i]);
}
bsearch(next,cham);
}
void Solve(int n) {
rep(i, 0, n*2) {
if (taken[i]) continue;
taken[i] = 1;
vi vec;
rep(j, 0, n*2) if (!taken[j]) vec.pb(j + 1);
bsearch(vec,i+1);
}
}