Submission #1022824

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
10228242024-07-14 05:52:21gygThe Xana coup (BOI21_xanadu)C++17
100 / 100
101 ms28452 KiB
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const int MAX_N = 1e5 + 5;
const lint INF = 1e9;
int n;
array<vector<int>, MAX_N> adj;
array<bool, MAX_N> a;
array<vector<int>, MAX_N> children;
void dfs1(int u = 1, int par = -1) {
for (int v : adj[u])
if (v != par) children[u].push_back(v), dfs1(v, u);
}
array<array<array<lint, 2>, 2>, MAX_N> dp1;
void dfs2(int u = 1) {
for (int v : children[u]) dfs2(v);
for (bool state : {false, true}) {
for (bool toggle : {false, true}) {
vector<array<lint, 2>> dp2(children[u].size() + 5);
dp2[0][1] = INF;
for (int i = 1; i <= children[u].size(); i++) {
int v = children[u][i - 1];
for (bool parity : {false, true}) {
lint leave = dp1[v][a[v] ^ toggle][0] + dp2[i - 1][parity];
lint take = dp1[v][a[v] ^ toggle ^ 1][1] + 1 + dp2[i - 1][parity ^ 1];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

xanadu.cpp: In function 'void dfs2(int)':
xanadu.cpp:26:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |             for (int i = 1; i <= children[u].size(); i++) {
      |                             ~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...