Submission #1120008

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
11200082024-11-27 16:51:34Captain_GeorgiaBall Machine (BOI13_ballmachine)C++17
100 / 100
240 ms33836 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int32_t main () {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int N, Q;
cin >> N >> Q;
vector<int> g[N];
int root = -1;
for (int i = 0;i < N;i ++) {
int p;
cin >> p;
-- p;
if (p != -1) g[p].push_back(i);
else root = i;
}
assert(root != -1);
const int lg = 20;
vector<vector<int>> up(lg, vector<int>(N, 0));
vector<int> tin(N, 0), tout(N, 0), submn(N), depth(N, 0);
int _time = 0;
function<void(int, int)> dfs_init = [&](int si, int pi) -> void {
up[0][si] = pi;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

ballmachine.cpp: In function 'int32_t main()':
ballmachine.cpp:67:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |     for (int i = 0;i < all.size();i ++) {
      |                    ~~^~~~~~~~~~~~
ballmachine.cpp:71:10: warning: variable 'is_ancestor' set but not used [-Wunused-but-set-variable]
   71 |     auto is_ancestor = [&](int x, int y) -> bool {
      |          ^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...