#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MASK(i) (1ULL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
#define ALL(v) (v).begin(), (v).end()
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll gcd(ll a, ll b){return __gcd(a, b);}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
ll LASTBIT(ll mask){return (mask) & (-mask);}
int pop_cnt(ull mask){return __builtin_popcountll(mask);}
int ctz(ull mask){return __builtin_ctzll(mask);}
int logOf(ull mask){return 63 - __builtin_clzll(mask);}
//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rng(1);
ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);}
template <class T1, class T2>
bool maximize(T1 &a, T2 b){
if (a < b) {a = b; return true;}
return false;
}
template <class T1, class T2>
bool minimize(T1 &a, T2 b){
if (a > b) {a = b; return true;}
return false;
}
template <class T>
void printArr(T container, string separator = " ", string finish = "\n", ostream &out = cout){
for(auto item: container) out << item << separator;
out << finish;
}
template <class T>
void remove_dup(vector<T> &a){
sort(ALL(a));
a.resize(unique(ALL(a)) - a.begin());
}
#include "koala.h"
int minValue(int n, int w) {
int a[n], b[n];
memset(a, 0, sizeof a); memset(b, 0, sizeof b);
a[0] = 1;
playRound(a, b);
if (b[0] < a[0]){
return 0;
}
else{
for(int i = 1; i < n; ++i) if (b[i] <= a[i]) return i;
}
assert(false);
return 0;
}
int maxValue(int n, int w) {
vector<int> S;
for(int i = 0; i < n; ++i) S.push_back(i);
for(int it = 0; it < 4; ++it){
int a[n], b[n]; memset(a, 0, sizeof a); memset(b, 0, sizeof b);
int dih = 100 / S.size();
for(int i: S) a[i] = dih;
playRound(a, b);
vector<int> T;
for(int i: S) if (b[i] > a[i]) T.push_back(i);
S = T;
}
return S[0];
}
bool cmp1(int x, int y){
const int n = 100;
if (x == y) return false;
vector<int> blocked_cells;
while(true){
int a[n], b[n];
memset(a, 0, sizeof a); memset(b, 0, sizeof b);
a[x] = a[y] = blocked_cells.size() + 1;
if (a[x] == 7) a[x] = a[y] = 8;
int dih = 100 - 2 * (blocked_cells.size() + 1);
for(int i: blocked_cells) a[i] = dih / blocked_cells.size();
playRound(a, b);
bool b1 = b[x] > a[x], b2 = b[y] > a[y];
if (b1 && b2){
for(int i = 0; i < n; ++i) if (i != x && i != y && b[i] <= a[i]) blocked_cells.push_back(i);
remove_dup(blocked_cells);
}
else if (b1) return false;
else return true;
}
}
int o_cnt = 0;
bool cmp2(int x, int y){
const int n = 100;
if (x == y) return false;
o_cnt++;
if (o_cnt > 700) assert(false);
int a[n], b[n];
memset(a, 0, sizeof a); memset(b, 0, sizeof b);
a[x] = a[y] = 101;
playRound(a, b);
if (b[x] > a[x]) return false;
return true;
}
int greaterValue(int n, int w) {
if (cmp1(0, 1)) return 1;
return 0;
}
void optimal_sort(vector<int> &a, function<bool(int, int)> cmp){
vector<int> ans;
for(int i: a){
int l = 0, r = ans.size();
while(l < r){
int mid = (l + r) >> 1;
if (cmp(i, ans[mid])) r = mid;
else l = mid + 1;
}
ans.insert(ans.begin() + l, i);
}
a = ans;
}
void allValues(int n, int w, int *P) {
o_cnt = 0;
if (w == 2*n) {
vector<int> perm(n);
for(int i = 0; i < n; ++i) perm[i] = i;
optimal_sort(perm, cmp2);
for(int i = 0; i < n; ++i) P[perm[i]] = i + 1;
} else {
vector<int> perm(n);
for(int i = 0; i < n; ++i) perm[i] = i;
optimal_sort(perm, cmp1);
for(int i = 0; i < n; ++i) P[perm[i]] = i + 1;
}
}
# | 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... |