#include "migrations.h"
#ifdef LOCAL
#include "algo/debug.h"
#else
template <typename... Args>
void dummy(Args&&... args){}
#define ps dummy
#endif
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
template<class T> using V = vector<T>;
using vi = V<int>;
using vb = V<bool>;
using vs = V<string>;
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define len(x) (int)((x).size())
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pb push_back
#define eb emplace_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define ai2 array<int,2>
#define ai3 array<int,3>
#define ai4 array<int,4>
#define ai5 array<int,5>
template<class T> int lwb(const V<T>& a, const T& b) { return lb(all(a),b)-begin(a); }
template<class T> int upb(const V<T>& a, const T& b) { return ub(all(a),b)-begin(a); }
template<class T> bool ckmin(T& a, const T& b) { return a > b ? a=b, true : false; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a=b, true : false; }
#define pct __builtin_popcountll
#define ctz __builtin_ctzll
#define clz __builtin_clzll
constexpr int p2(int x) { return (int)1 << x; }
constexpr int msk2(int x) { return (int)(1 << x) - 1; }
constexpr int bits(int x) { return x == 0 ? 0 : 63-clz(x); } // floor(log2(x))
template<class T>void UNIQUE(V<T>& v) { sort(all(v)); v.erase(unique(all(v)),end(v)); }
template<class T, class Cmp>void UNIQUE(V<T>& v, Cmp cmp) { sort(all(v), cmp); v.erase(unique(all(v)),end(v)); }
template<class T,class U>void erase(T& t, const U& u) { auto it = t.find(u); assert(it != end(t)); t.erase(it); }
template<class F> struct y_combinator_result {
F f;
template<class T> explicit y_combinator_result(T &&f): f(std::forward<T>(f)) {}
template<class ...Args> decltype(auto) operator()(Args &&...args) { return f(std::ref(*this), std::forward<Args>(args)...); }
};
template<class Fun> decltype(auto) yy(Fun &&fun) { return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun)); }
template<class T> using pqg = priority_queue<T,vector<T>,greater<T>>;
const int n = 10000, k = 10;
array<bool, n> par;
array<int, n> dep;
int max_dep, last;
int send_message(int _, int i, int p) {
par[i] = p;
dep[i] = dep[p] + 1;
if (ckmax(max_dep, dep[i]))
last = i;
if (i >= n - k && last == i)
return 4;
if (i >= n - k * k && last == i - k)
return 3;
if (i >= n - k * k * k && last == i - k * k)
return 2;
if (last == i - k * k * k)
return 1;
return 0;
}
pair<int, int> longest_path(vi mm) {
int ans = 0;
for (int i = 0; i < n; i++) if (mm[i]) {
int cand;
if (mm[i] == 4) {
cand = i;
}
if (mm[i] == 3) {
cand = i - k;
}
if (mm[i] == 2) {
cand = i - k * k;
}
if (mm[i] == 1) {
cand = i - k * k * k;
}
ckmax(ans, cand);
}
return { 0, ans };
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |