Submission #1056369

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
10563692024-08-13 09:03:07PiokemonThe Xana coup (BOI21_xanadu)C++17
100 / 100
35 ms17780 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
constexpr int N = 100'000;
int a[N+9];
vector<int> graf[N+9];
ll dp[N+9][2][2];
ll dp2[N+9][2][2];
void dfs(int v, int par){
if (graf[v].size()==1 && v!=1){
dp[v][a[v]][0]=0;
dp[v][1-a[v]][1]=1;
dp[v][a[v]][1]=1e9;
dp[v][1-a[v]][0]=1e9;
return;
}
int nr=1;
dp2[0][0][0]=0; dp2[0][0][1]=1e9;
dp2[0][1][0]=0; dp2[0][1][1]=1e9;
ll s0=0,s1=0;
for (int x:graf[v]){
if (x==par)continue;
dfs(x,v);
}
for (int x:graf[v]){
if (x==par)continue;
for (int z=0;z<2;z++){
dp2[nr][z][0]=min(dp2[nr-1][z][0]+dp[x][z][0],dp2[nr-1][z][1]+dp[x][z][1]);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

xanadu.cpp: In function 'void dfs(int, int)':
xanadu.cpp:22:8: warning: unused variable 's0' [-Wunused-variable]
   22 |     ll s0=0,s1=0;
      |        ^~
xanadu.cpp:22:13: warning: unused variable 's1' [-Wunused-variable]
   22 |     ll s0=0,s1=0;
      |             ^~
#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...